aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug.xml8
-rw-r--r--src/org/traccar/database/DataManager.java18
-rw-r--r--src/org/traccar/model/Schema.java29
-rw-r--r--web/app/store/SpeedUnits.js4
-rw-r--r--web/l10n/de.js2
-rw-r--r--web/l10n/en.js2
-rw-r--r--web/l10n/es.js2
-rw-r--r--web/l10n/fr.js2
-rw-r--r--web/l10n/pl.js2
-rw-r--r--web/l10n/pt.js2
-rw-r--r--web/l10n/ru.js2
-rw-r--r--web/l10n/th.js2
-rw-r--r--web/l10n/zh.js2
13 files changed, 66 insertions, 11 deletions
diff --git a/debug.xml b/debug.xml
index f33a350c4..8dea1ae59 100644
--- a/debug.xml
+++ b/debug.xml
@@ -45,6 +45,10 @@
<entry key='database.checkTable'>traccar</entry>
+ <entry key='database.selectSchemaVersion'>
+ SELECT * FROM traccar;
+ </entry>
+
<entry key='database.createSchema'>
CREATE TABLE "user" (
id INT PRIMARY KEY AUTO_INCREMENT,
@@ -79,6 +83,8 @@
FOREIGN KEY (userId) REFERENCES "user" (id) ON DELETE CASCADE,
FOREIGN KEY (deviceId) REFERENCES device (id) ON DELETE CASCADE);
+ CREATE INDEX user_device_userId ON user_device(userId);
+
CREATE TABLE position (
id INT PRIMARY KEY AUTO_INCREMENT,
protocol VARCHAR(128),
@@ -126,6 +132,8 @@
CREATE TABLE traccar (
version INT DEFAULT 0 NOT NULL);
+
+ INSERT INTO traccar (version) VALUES (301);
</entry>
<entry key='database.selectServers'>
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;
}
diff --git a/src/org/traccar/model/Schema.java b/src/org/traccar/model/Schema.java
new file mode 100644
index 000000000..1878f0edb
--- /dev/null
+++ b/src/org/traccar/model/Schema.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.model;
+
+public class Schema implements Factory {
+
+ @Override
+ public Schema create() {
+ return new Schema();
+ }
+
+ private int version;
+ public int getVersion() { return version; }
+ public void setVersion(int version) { this.version = version; }
+
+}
diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js
index 95c7fbc3b..450716039 100644
--- a/web/app/store/SpeedUnits.js
+++ b/web/app/store/SpeedUnits.js
@@ -18,13 +18,13 @@ Ext.define('Traccar.store.SpeedUnits', {
extend: 'Ext.data.Store',
fields: ['key', 'name'],
data: [
- {'key': 'kph', 'name': strings.shared_kph},
+ {'key': 'kmh', 'name': strings.shared_kmh},
{'key': 'mph', 'name': strings.shared_mph}
],
convert: function(value, unit) {
switch (unit) {
- case 'kph':
+ case 'kmh':
return value * 1.852;
case 'mph':
return value * 1.15078;
diff --git a/web/l10n/de.js b/web/l10n/de.js
index 47a214c83..4554cad62 100644
--- a/web/l10n/de.js
+++ b/web/l10n/de.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Objekt entfernen?',
shared_km: 'km',
shared_mi: 'mi',
- shared_kph: 'km/h',
+ shared_kmh: 'km/h',
shared_mph: 'mph',
shared_hour: 'Stunde',
shared_minute: 'Minute',
diff --git a/web/l10n/en.js b/web/l10n/en.js
index 77d6bff83..2a6ca666e 100644
--- a/web/l10n/en.js
+++ b/web/l10n/en.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Remove item?',
shared_km: 'km',
shared_mi: 'mi',
- shared_kph: 'km/h',
+ shared_kmh: 'km/h',
shared_mph: 'mph',
shared_hour: 'Hour',
shared_minute: 'Minute',
diff --git a/web/l10n/es.js b/web/l10n/es.js
index 89ea8486f..81fb2a662 100644
--- a/web/l10n/es.js
+++ b/web/l10n/es.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Borrar elemento?',
shared_km: 'km',
shared_mi: 'mi',
- shared_kph: 'km/h',
+ shared_kmh: 'km/h',
shared_mph: 'mph',
shared_hour: 'Hora',
shared_minute: 'Minuto',
diff --git a/web/l10n/fr.js b/web/l10n/fr.js
index 0d433fa9b..1d33c0063 100644
--- a/web/l10n/fr.js
+++ b/web/l10n/fr.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Effacer item?',
shared_km: 'km',
shared_mi: 'mi',
- shared_kph: 'km/h',
+ shared_kmh: 'km/h',
shared_mph: 'mph',
shared_hour: 'Heure',
shared_minute: 'Minute',
diff --git a/web/l10n/pl.js b/web/l10n/pl.js
index 05f64711a..815cde2f2 100644
--- a/web/l10n/pl.js
+++ b/web/l10n/pl.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Usuń obiekt?',
shared_km: 'km',
shared_mi: 'mi',
- shared_kph: 'km/h',
+ shared_kmh: 'km/h',
shared_mph: 'mph',
shared_hour: 'Godzina',
shared_minute: 'Minuta',
diff --git a/web/l10n/pt.js b/web/l10n/pt.js
index ed1350f6e..2ddf2b11f 100644
--- a/web/l10n/pt.js
+++ b/web/l10n/pt.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Remove item?',
shared_km: 'Km',
shared_mi: 'mi',
- shared_kph: 'Km/h',
+ shared_kmh: 'Km/h',
shared_mph: 'Mph',
shared_hour: 'Hora',
shared_minute: 'Minuto',
diff --git a/web/l10n/ru.js b/web/l10n/ru.js
index 605717eeb..adb67c958 100644
--- a/web/l10n/ru.js
+++ b/web/l10n/ru.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'Удалить элемент?',
shared_km: 'км',
shared_mi: 'мили',
- shared_kph: 'км/ч',
+ shared_kmh: 'км/ч',
shared_mph: 'миль/ч',
shared_hour: 'Часы',
shared_minute: 'Минуты',
diff --git a/web/l10n/th.js b/web/l10n/th.js
index ebcb88953..751689b16 100644
--- a/web/l10n/th.js
+++ b/web/l10n/th.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: 'ลบรายการ',
shared_km: 'กม.',
shared_mi: 'ไมล์',
- shared_kph: 'กม. / ชม',
+ shared_kmh: 'กม. / ชม',
shared_mph: 'ไมล์ต่อชั่วโมง',
shared_hour: 'ชั่วโมง',
shared_minute: 'นาที',
diff --git a/web/l10n/zh.js b/web/l10n/zh.js
index cf76e4e35..49f8c8600 100644
--- a/web/l10n/zh.js
+++ b/web/l10n/zh.js
@@ -8,7 +8,7 @@ var strings = {
shared_remove_confirm: '要移除选项吗?',
shared_km: '千米',
shared_mi: '海里',
- shared_kph: '千米/小时',
+ shared_kmh: '千米/小时',
shared_mph: '每小时英里数',
shared_hour: '小时',
shared_minute: '分钟',