diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-02-10 16:54:18 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-02-10 16:54:18 +1300 |
commit | e4981d8e06f730a145ceaa4aa874533591ed0695 (patch) | |
tree | 00ac5ebdc7d1516cee0f817587e31e730cb07368 /src | |
parent | c37b9de4b1a5d678c191f209b2b8f2447492a5c3 (diff) | |
download | traccar-server-e4981d8e06f730a145ceaa4aa874533591ed0695.tar.gz traccar-server-e4981d8e06f730a145ceaa4aa874533591ed0695.tar.bz2 traccar-server-e4981d8e06f730a145ceaa4aa874533591ed0695.zip |
More database init code
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 336ac3e34..602345df9 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -225,11 +225,39 @@ public class DataManager { try { statement.execute( - "CREATE TABLE users_new (" + + "CREATE TABLE IF NOT EXISTS users (" + "id INT PRIMARY KEY AUTO_INCREMENT," + "name VARCHAR(1024) NOT NULL UNIQUE," + "password VARCHAR(1024) NOT NULL," + - "admin BOOLEAN NOT NULL)"); + "admin BOOLEAN NOT NULL);"); + + statement.execute( + "CREATE TABLE IF NOT EXISTS devices (" + + "id INT PRIMARY KEY AUTO_INCREMENT," + + "name VARCHAR(1024) NOT NULL," + + "uniqueId VARCHAR(1024) NOT NULL UNIQUE);"); + + statement.execute( + "CREATE TABLE IF NOT EXISTS users_devices (" + + "userId INT NOT NULL," + + "deviceId INT NOT NULL," + + "FOREIGN KEY (userId) REFERENCES users(id)," + + "FOREIGN KEY (deviceId) REFERENCES devices(id));"); + + statement.execute( + "CREATE TABLE IF NOT EXISTS positions (" + + "id INT PRIMARY KEY AUTO_INCREMENT," + + "deviceId INT NOT NULL," + + "time TIMESTAMP NOT NULL," + + "valid BOOLEAN NOT NULL," + + "latitude DOUBLE NOT NULL," + + "longitude DOUBLE NOT NULL," + + "altitude DOUBLE NOT NULL," + + "speed DOUBLE NOT NULL," + + "course DOUBLE NOT NULL," + + "address VARCHAR(1024) NOT NULL," + + "other VARCHAR(8192) NOT NULL," + + "FOREIGN KEY (deviceId) REFERENCES devices(id));"); } finally { statement.close(); |