Skip to content

Commit

Permalink
Fixed initial db load for openshift.
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaless committed Apr 15, 2012
1 parent f6f5670 commit b3811c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;

import models.Country;
import play.Application;
Expand Down Expand Up @@ -91,7 +92,12 @@ public static void checkAndDoInitialization(Application app) {
/*
* Insert required data
*/
BufferedReader in = new BufferedReader(new FileReader("conf/initial-data.sql"));
String path = "conf/initial-data.sql";
Map<String, String> env = System.getenv();
if (env.containsKey("OPENSHIFT_REPO_DIR")) {
path = env.get("OPENSHIFT_REPO_DIR") + "/" + path;
}
BufferedReader in = new BufferedReader(new FileReader(path));
conn.setAutoCommit(false); /* Turn off auto commit so the below are done as one transaction */
String line;
while((line = in.readLine()) != null) {
Expand Down

0 comments on commit b3811c9

Please sign in to comment.