From 20f627361ca717ef7c4d74b491cf50efecab4467 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 7 Aug 2015 19:17:52 +1200 Subject: Update release config files --- setup/linux/traccar.xml | 146 ++++++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 54 deletions(-) (limited to 'setup/linux') diff --git a/setup/linux/traccar.xml b/setup/linux/traccar.xml index 10f9cceae..139b4fec8 100644 --- a/setup/linux/traccar.xml +++ b/setup/linux/traccar.xml @@ -23,30 +23,35 @@ jdbc:h2:/opt/traccar/data/database sa + traccar + + SELECT * FROM traccar; + + - CREATE TABLE user ( + CREATE TABLE "user" ( id INT PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(1024) NOT NULL, - email VARCHAR(256) NOT NULL UNIQUE, - hashedPassword VARCHAR(1024) NOT NULL, - salt VARCHAR(1024) DEFAULT '' NOT NULL, - readonly BOOLEAN DEFAULT false NOT NULL, - admin BOOLEAN DEFAULT false NOT NULL, - map VARCHAR(1024) DEFAULT 'osm' NOT NULL, - language VARCHAR(1024) DEFAULT 'en' NOT NULL, - distanceUnit VARCHAR(1024) DEFAULT 'km' NOT NULL, - speedUnit VARCHAR(1024) DEFAULT 'kmh' NOT NULL, - latitude DOUBLE DEFAULT 0 NOT NULL, - longitude DOUBLE DEFAULT 0 NOT NULL, + name VARCHAR(128) NOT NULL, + email VARCHAR(128) NOT NULL UNIQUE, + hashedPassword VARCHAR(128) NOT NULL, + salt VARCHAR(128) DEFAULT '' NOT NULL, + readonly BIT DEFAULT 0 NOT NULL, + admin BIT DEFAULT 0 NOT NULL, + map VARCHAR(128), + language VARCHAR(128), + distanceUnit VARCHAR(128), + speedUnit VARCHAR(128), + latitude FLOAT DEFAULT 0 NOT NULL, + longitude FLOAT DEFAULT 0 NOT NULL, zoom INT DEFAULT 0 NOT NULL); CREATE TABLE device ( id INT PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(1024) NOT NULL, - uniqueId VARCHAR(256) NOT NULL UNIQUE, - status VARCHAR(1024), + name VARCHAR(128) NOT NULL, + uniqueId VARCHAR(128) NOT NULL UNIQUE, + status VARCHAR(128), lastUpdate TIMESTAMP, positionId INT, dataId INT); @@ -54,54 +59,62 @@ CREATE TABLE user_device ( userId INT NOT NULL, deviceId INT NOT NULL, - `read` BOOLEAN DEFAULT true NOT NULL, - `write` BOOLEAN DEFAULT true NOT NULL, - FOREIGN KEY (userId) REFERENCES user(id) ON DELETE CASCADE, - FOREIGN KEY (deviceId) REFERENCES device(id) ON DELETE CASCADE); + "read" BIT DEFAULT 1 NOT NULL, + "write" BIT DEFAULT 1 NOT NULL, + FOREIGN KEY (userId) REFERENCES "user" (id) ON DELETE CASCADE, + FOREIGN KEY (deviceId) REFERENCES device (id) ON DELETE CASCADE); - CREATE INDEX user_device_user_id ON user_device(userId); + CREATE INDEX user_device_userId ON user_device(userId); CREATE TABLE position ( id INT PRIMARY KEY AUTO_INCREMENT, - protocol VARCHAR(1024), + protocol VARCHAR(128), deviceId INT NOT NULL, serverTime TIMESTAMP NOT NULL, deviceTime TIMESTAMP NOT NULL, fixTime 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), - other VARCHAR(8192) NOT NULL, - FOREIGN KEY (deviceId) REFERENCES device(id) ON DELETE CASCADE); + valid BIT NOT NULL, + latitude FLOAT NOT NULL, + longitude FLOAT NOT NULL, + altitude FLOAT NOT NULL, + speed FLOAT NOT NULL, + course FLOAT NOT NULL, + address VARCHAR(512), + other VARCHAR(4096) NOT NULL, + FOREIGN KEY (deviceId) REFERENCES device (id) ON DELETE CASCADE); + + CREATE INDEX position_deviceId_fixTime ON position (deviceId, fixTime); CREATE TABLE data ( id INT PRIMARY KEY AUTO_INCREMENT, - protocol VARCHAR(1024), + protocol VARCHAR(128), deviceId INT NOT NULL, serverTime TIMESTAMP NOT NULL, deviceTime TIMESTAMP NOT NULL, - other VARCHAR(8192) NOT NULL, - FOREIGN KEY (deviceId) REFERENCES device(id)); + other VARCHAR(4096) NOT NULL, + FOREIGN KEY (deviceId) REFERENCES device (id)); ALTER TABLE device ADD - FOREIGN KEY (positionId) REFERENCES `position`(id); + FOREIGN KEY (positionId) REFERENCES position (id); ALTER TABLE device ADD - FOREIGN KEY (dataId) REFERENCES data(id); + FOREIGN KEY (dataId) REFERENCES data (id); CREATE TABLE server ( id INT PRIMARY KEY AUTO_INCREMENT, - registration BOOLEAN NOT NULL, - latitude DOUBLE NOT NULL, - longitude DOUBLE NOT NULL, - zoom INT NOT NULL); + registration BIT NOT NULL, + map VARCHAR(128), + language VARCHAR(128), + distanceUnit VARCHAR(128), + speedUnit VARCHAR(128), + latitude FLOAT DEFAULT 0 NOT NULL, + longitude FLOAT DEFAULT 0 NOT NULL, + zoom INT DEFAULT 0 NOT NULL); CREATE TABLE traccar ( - id INT PRIMARY KEY AUTO_INCREMENT); + version INT DEFAULT 0 NOT NULL); + + INSERT INTO traccar (version) VALUES (301); @@ -114,34 +127,58 @@ - UPDATE server SET registration = :registration WHERE id = :id; + UPDATE server SET + registration = :registration, + map = :map, + language = :language, + distanceUnit = :distanceUnit, + speedUnit = :speedUnit, + latitude = :latitude, + longitude = :longitude, + zoom = :zoom + WHERE id = :id; - SELECT * FROM user + SELECT * FROM "user" WHERE email = :email; + + SELECT * FROM "user" + WHERE id = :id; + + - SELECT * FROM user; + SELECT * FROM "user"; - INSERT INTO user (name, email, hashedPassword, salt, admin) + INSERT INTO "user" (name, email, hashedPassword, salt, admin) VALUES (:name, :email, :hashedPassword, :salt, :admin); - UPDATE user SET name = :name, email = :email, admin = :admin + UPDATE "user" SET + name = :name, + email = :email, + admin = :admin, + map = :map, + language = :language, + distanceUnit = :distanceUnit, + speedUnit = :speedUnit, + latitude = :latitude, + longitude = :longitude, + zoom = :zoom WHERE id = :id; - UPDATE user SET hashedPassword = :hashedPassword, salt = :salt WHERE id = :id; + UPDATE "user" SET hashedPassword = :hashedPassword, salt = :salt WHERE id = :id; - DELETE FROM user WHERE id = :id; + DELETE FROM "user" WHERE id = :id; @@ -177,8 +214,8 @@ - INSERT INTO position (deviceId, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, other) - VALUES (:deviceId, NOW(), :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :other); + INSERT INTO position (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, other) + VALUES (:deviceId, :protocol, CURRENT_TIMESTAMP(), :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :other); @@ -221,9 +258,9 @@ 5026 5027 5028 - 5029 + 5029 5030 - 5031 + 5031 5032 5033 5034 @@ -242,7 +279,6 @@ 5047 5048 5049 - false 5050 5051 5052 @@ -250,7 +286,7 @@ 5054 5055 5056 - 5057 + 5057 5058 5059 5060 @@ -280,5 +316,7 @@ 5084 5085 5086 + 5087 + 5088 -- cgit v1.2.3