aboutsummaryrefslogtreecommitdiff
path: root/database/changelog-3.3.xml
diff options
context:
space:
mode:
Diffstat (limited to 'database/changelog-3.3.xml')
-rw-r--r--database/changelog-3.3.xml187
1 files changed, 187 insertions, 0 deletions
diff --git a/database/changelog-3.3.xml b/database/changelog-3.3.xml
new file mode 100644
index 000000000..25b359401
--- /dev/null
+++ b/database/changelog-3.3.xml
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
+
+ <changeSet author="author" id="changelog-3.3">
+
+ <preConditions onFail="MARK_RAN">
+ <not>
+ <tableExists tableName="server" />
+ </not>
+ </preConditions>
+
+ <createTable tableName="users">
+ <column name="id" type="INT" autoIncrement="true">
+ <constraints primaryKey="true" />
+ </column>
+ <column name="name" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="email" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="hashedPassword" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="salt" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="readonly" type="BOOLEAN" defaultValueBoolean="false">
+ <constraints nullable="false" />
+ </column>
+ <column name="admin" type="BOOLEAN" defaultValueBoolean="false">
+ <constraints nullable="false" />
+ </column>
+ <column name="map" type="VARCHAR(128)" defaultValue="osm">
+ <constraints nullable="false" />
+ </column>
+ <column name="language" type="VARCHAR(128)" defaultValue="en">
+ <constraints nullable="false" />
+ </column>
+ <column name="distanceUnit" type="VARCHAR(128)" defaultValue="km">
+ <constraints nullable="false" />
+ </column>
+ <column name="speedUnit" type="VARCHAR(128)" defaultValue="kmh">
+ <constraints nullable="false" />
+ </column>
+ <column name="latitude" type="DOUBLE" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ <column name="longitude" type="DOUBLE" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ <column name="zoom" type="INT" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ </createTable>
+
+ <addUniqueConstraint tableName="users" columnNames="email" constraintName="uk_user_email" />
+
+ <createTable tableName="devices">
+ <column name="id" type="INT" autoIncrement="true">
+ <constraints primaryKey="true" />
+ </column>
+ <column name="name" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="uniqueId" type="VARCHAR(128)">
+ <constraints nullable="false" />
+ </column>
+ <column name="status" type="VARCHAR(128)" />
+ <column name="lastUpdate" type="TIMESTAMP" />
+ <column name="positionId" type="INT" />
+ </createTable>
+
+ <addUniqueConstraint tableName="devices" columnNames="uniqueId" constraintName="uk_device_uniqueId" />
+
+ <createTable tableName="user_device">
+ <column name="userId" type="INT">
+ <constraints nullable="false" />
+ </column>
+ <column name="deviceId" type="INT">
+ <constraints nullable="false" />
+ </column>
+ </createTable>
+
+ <addForeignKeyConstraint baseTableName="user_device" baseColumnNames="userId" constraintName="fk_user_device_userId" referencedTableName="users" referencedColumnNames="id" onDelete="CASCADE" />
+ <addForeignKeyConstraint baseTableName="user_device" baseColumnNames="deviceId" constraintName="fk_user_device_deviceId" referencedTableName="devices" referencedColumnNames="id" onDelete="CASCADE" />
+
+ <createIndex tableName="user_device" indexName="user_device_user_id">
+ <column name="userId" />
+ </createIndex>
+
+ <createTable tableName="positions">
+ <column name="id" type="INT" autoIncrement="true">
+ <constraints primaryKey="true" />
+ </column>
+ <column name="protocol" type="VARCHAR(128)" />
+ <column name="deviceId" type="int">
+ <constraints nullable="false" />
+ </column>
+ <column name="serverTime" type="TIMESTAMP">
+ <constraints nullable="false" />
+ </column>
+ <column name="deviceTime" type="TIMESTAMP">
+ <constraints nullable="false" />
+ </column>
+ <column name="fixTime" type="TIMESTAMP">
+ <constraints nullable="false" />
+ </column>
+ <column name="valid" type="BOOLEAN">
+ <constraints nullable="false" />
+ </column>
+ <column name="latitude" type="DOUBLE">
+ <constraints nullable="false" />
+ </column>
+ <column name="longitude" type="DOUBLE">
+ <constraints nullable="false" />
+ </column>
+ <column name="altitude" type="FLOAT">
+ <constraints nullable="false" />
+ </column>
+ <column name="speed" type="FLOAT">
+ <constraints nullable="false" />
+ </column>
+ <column name="course" type="FLOAT">
+ <constraints nullable="false" />
+ </column>
+ <column name="address" type="VARCHAR(512)" />
+ <column name="attributes" type="VARCHAR(4096)">
+ <constraints nullable="false" />
+ </column>
+ </createTable>
+
+ <addForeignKeyConstraint baseTableName="positions" baseColumnNames="deviceId" constraintName="fk_position_deviceId" referencedTableName="devices" referencedColumnNames="id" onDelete="CASCADE" />
+
+ <createIndex tableName="positions" indexName="position_deviceId_fixTime">
+ <column name="deviceId" />
+ <column name="fixTime" />
+ </createIndex>
+
+ <createTable tableName="server">
+ <column name="id" type="INT" autoIncrement="true">
+ <constraints primaryKey="true" />
+ </column>
+ <column name="registration" type="BOOLEAN" defaultValueBoolean="true">
+ <constraints nullable="false" />
+ </column>
+ <column name="latitude" type="DOUBLE" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ <column name="longitude" type="DOUBLE" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ <column name="zoom" type="INT" defaultValueNumeric="0">
+ <constraints nullable="false" />
+ </column>
+ <column name="map" type="VARCHAR(128)" />
+ <column name="language" type="VARCHAR(128)" />
+ <column name="distanceUnit" type="VARCHAR(128)" />
+ <column name="speedUnit" type="VARCHAR(128)" />
+ <column name="bingKey" type="VARCHAR(128)" />
+ <column name="mapUrl" type="VARCHAR(128)" />
+ <column name="readonly" type="BOOLEAN" defaultValueBoolean="false">
+ <constraints nullable="false" />
+ </column>
+ </createTable>
+
+ <insert tableName="server">
+ <column name="registration" valueBoolean="true" />
+ <column name="latitude" valueNumeric="0" />
+ <column name="longitude" valueNumeric="0" />
+ <column name="zoom" valueNumeric="0" />
+ </insert>
+
+ <insert tableName="users">
+ <column name="name" value="admin" />
+ <column name="email" value="admin" />
+ <column name="hashedPassword" value="D33DCA55ABD4CC5BC76F2BC0B4E603FE2C6F61F4C1EF2D47" />
+ <column name="salt" value="000000000000000000000000000000000000000000000000" />
+ <column name="admin" valueBoolean="true" />
+ </insert>
+
+ </changeSet>
+</databaseChangeLog>