Fix Postgre db script issues

4.x.x
Charitha Goonetilleke 5 years ago
parent ac0f9f9751
commit d642a7287f

@ -490,26 +490,31 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS (
(
ID BIGSERIAL NOT NULL PRIMARY KEY, ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_ID INT NOT NULL, DEVICE_ID INTEGER NOT NULL,
DEVICE_ID_NAME VARCHAR(255) NOT NULL, DEVICE_ID_NAME VARCHAR(255) NOT NULL,
TENANT_ID INT NOT NULL, TENANT_ID INTEGER NOT NULL,
DEVICE_TYPE_NAME VARCHAR(45) NOT NULL, DEVICE_TYPE_NAME VARCHAR(45) NOT NULL,
LATITUDE DOUBLE PRECISION NULL, LATITUDE DOUBLE PRECISION NULL,
LONGITUDE DOUBLE PRECISION NULL, LONGITUDE DOUBLE PRECISION NULL,
SPEED FLOAT NULL, SPEED FLOAT NULL,
HEADING FLOAT NULL, HEADING FLOAT NULL,
TIMESTAMP BIGINT(15) NOT NULL, TIMESTAMP BIGINT NOT NULL,
GEO_HASH VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL,
DEVICE_OWNER VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL,
DEVICE_ALTITUDE DOUBLE PRECISION NULL, DEVICE_ALTITUDE DOUBLE PRECISION NULL,
DISTANCE DOUBLE PRECISION NULL, DISTANCE DOUBLE PRECISION NULL,
CONSTRAINT DM_DEVICE_HISTORY_LAST_SEVEN_DAYS
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
); );
CREATE INDEX DM_DEVICE_HISTORY_LAST_SEVEN_DAYS_GEO_hashx ON DM_DEVICE_HISTORY_LAST_SEVEN_DAYS(GEO_HASH ASC);
CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID BIGSERIAL NOT NULL PRIMARY KEY, ID BIGSERIAL NOT NULL PRIMARY KEY,
@ -543,20 +548,19 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE SEQUENCE `DM_DEVICE_TYPE_PLATFORM`_seq; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_PLATFORM (
ID BIGSERIAL NOT NULL PRIMARY KEY,
CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE_PLATFORM` (
ID INT NOT NULL DEFAULT NEXTVAL ('`DM_DEVICE_TYPE_PLATFORM`_seq'),
DEVICE_TYPE_ID INT DEFAULT 0, DEVICE_TYPE_ID INT DEFAULT 0,
VERSION_NAME VARCHAR(100) NULL, VERSION_NAME VARCHAR(100) NULL,
VERSION_STATUS VARCHAR(100) DEFAULT 'ACTIVE', VERSION_STATUS VARCHAR(100) DEFAULT 'ACTIVE',
PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_TYPE_PLATFORM_MAPPING
CONSTRAINT DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING FOREIGN KEY (DEVICE_TYPE_ID) FOREIGN KEY (DEVICE_TYPE_ID)
REFERENCES DM_DEVICE_TYPE (ID) REFERENCES DM_DEVICE_TYPE (ID)
ON DELETE CASCADE ON DELETE NO ACTION
ON UPDATE CASCADE, ON UPDATE NO ACTION,
CONSTRAINT device_type_version_uk UNIQUE (DEVICE_TYPE_ID, VERSION_NAME) CONSTRAINT device_type_version_uk
) UNIQUE (DEVICE_TYPE_ID, VERSION_NAME)
);
-- DASHBOARD RELATED VIEWS -- -- DASHBOARD RELATED VIEWS --

Loading…
Cancel
Save