diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-02 16:53:24 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-02 16:53:24 +1200 |
commit | 2617753615e47acb6600a7d551c4f6508f5af91f (patch) | |
tree | 33497cb97473da56ce339b5b0acc29628a913af5 /src/org/traccar/database | |
parent | 6f47747e6a438037392794f72ac91dbce6cc6683 (diff) | |
download | traccar-server-2617753615e47acb6600a7d551c4f6508f5af91f.tar.gz traccar-server-2617753615e47acb6600a7d551c4f6508f5af91f.tar.bz2 traccar-server-2617753615e47acb6600a7d551c4f6508f5af91f.zip |
Add database schema version
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 4c12ecd77..3cfeadae4 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -38,6 +38,7 @@ import org.traccar.model.Device; import org.traccar.model.MiscFormatter; import org.traccar.model.Permission; import org.traccar.model.Position; +import org.traccar.model.Schema; import org.traccar.model.Server; import org.traccar.model.User; import org.traccar.web.AsyncServlet; @@ -157,6 +158,23 @@ public class DataManager implements IdentityManager { } } if (exist) { + + String schemaVersionQuery = getQuery("database.selectSchemaVersion"); + if (schemaVersionQuery != null) { + + Schema schema = QueryBuilder.create(dataSource, schemaVersionQuery).executeQuerySingle(new Schema()); + + int version = 0; + if (schema != null) { + version = schema.getVersion(); + } + + if (version != 301) { + Log.error("Wrong database schema version (" + version + ")"); + throw new RuntimeException(); + } + } + return; } |