aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-17 15:47:18 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-17 15:47:18 +1300
commit3b0019a516a732e1a0cdbde1d2ce58a1c96cf953 (patch)
tree00389392dacf9066e46c813dc5d566b1443251b4 /src
parent48305c4c43c79a9575cf7573990e5127bbe88950 (diff)
downloadtrackermap-server-3b0019a516a732e1a0cdbde1d2ce58a1c96cf953.tar.gz
trackermap-server-3b0019a516a732e1a0cdbde1d2ce58a1c96cf953.tar.bz2
trackermap-server-3b0019a516a732e1a0cdbde1d2ce58a1c96cf953.zip
Start Liquibase library integration
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/database/DataManager.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 7d8966d9a..caf6d9db3 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -30,6 +30,15 @@ import java.util.HashMap;
import java.util.Map;
import javax.naming.InitialContext;
import javax.sql.DataSource;
+
+import liquibase.Contexts;
+import liquibase.Liquibase;
+import liquibase.database.Database;
+import liquibase.database.DatabaseFactory;
+import liquibase.exception.DatabaseException;
+import liquibase.exception.LiquibaseException;
+import liquibase.resource.FileSystemResourceAccessor;
+import liquibase.resource.ResourceAccessor;
import org.traccar.Config;
import org.traccar.helper.DriverDelegate;
import org.traccar.helper.Log;
@@ -147,10 +156,27 @@ public class DataManager implements IdentityManager {
return query;
}
- private void initDatabaseSchema() throws SQLException {
+ private void initDatabaseSchema() throws SQLException, LiquibaseException {
if (config.getString("web.type", "new").equals("new") || config.getString("web.type", "new").equals("api")) {
+ /*try {
+ ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
+
+ Database database = DatabaseFactory.getInstance().openDatabase(
+ config.getString("database.url"),
+ config.getString("database.user"),
+ config.getString("database.password"),
+ null, resourceAccessor);
+
+ Liquibase liquibase = new Liquibase(
+ config.getString("database.changelog"), new FileSystemResourceAccessor(), database);
+
+ liquibase.update(new Contexts());
+ } catch (Exception e) {
+ Log.warning(e);
+ }*/
+
boolean exist = false;
try (Connection connection = dataSource.getConnection();