Fixed errors in PostgreSQL script

4.x.x
Dileesha Rajapakse 9 years ago
parent 13c5fe3d1b
commit de08e96646

@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
ID BIGSERIAL NOT NULL PRIMARY KEY, ID BIGSERIAL NOT NULL PRIMARY KEY,
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
CERTIFICATE BYTEA DEFAULT NULL CERTIFICATE BYTEA DEFAULT NULL,
TENANT_ID INTEGER DEFAULT 0, TENANT_ID INTEGER DEFAULT 0
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE TABLE IF NOT EXISTS DM_DEVICE (
@ -292,10 +292,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE SEQUENCE DM_DEVICE_GROUP_POLICY_seq;
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
ID INT NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_GROUP_POLICY_seq'), ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_GROUP_ID INT NOT NULL, DEVICE_GROUP_ID INT NOT NULL,
POLICY_ID INT NOT NULL, POLICY_ID INT NOT NULL,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
@ -373,11 +372,10 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_INFO_seq') NOT NULL, ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_ID INT NULL, DEVICE_ID INT NULL,
KEY_FIELD VARCHAR(45) NULL, KEY_FIELD VARCHAR(45) NULL,
VALUE_FIELD VARCHAR(100) NULL, VALUE_FIELD VARCHAR(100) NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_INFO_DEVICE CONSTRAINT DM_DEVICE_INFO_DEVICE
FOREIGN KEY (DEVICE_ID) FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID) REFERENCES DM_DEVICE (ID)
@ -385,11 +383,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE INDEX DM_DEVICE_INFO_DEVICE_idx ON DM_DEVICE_INFO (DEVICE_ID ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_LOCATION_seq') NOT NULL, ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_ID INT NULL, DEVICE_ID INT NULL,
LATITUDE DOUBLE PRECISION NULL, LATITUDE DOUBLE PRECISION NULL,
LONGITUDE DOUBLE PRECISION NULL, LONGITUDE DOUBLE PRECISION NULL,
@ -400,7 +396,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
STATE VARCHAR(45) NULL, STATE VARCHAR(45) NULL,
COUNTRY VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL,
UPDATE_TIMESTAMP BIGINT NOT NULL, UPDATE_TIMESTAMP BIGINT NOT NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_LOCATION_DEVICE CONSTRAINT DM_DEVICE_LOCATION_DEVICE
FOREIGN KEY (DEVICE_ID) FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID) REFERENCES DM_DEVICE (ID)
@ -408,13 +403,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE INDEX DM_DEVICE_LOCATION_DEVICE_idx ON DM_DEVICE_LOCATION (DEVICE_ID ASC);
CREATE SEQUENCE DM_DEVICE_DETAIL_seq;
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_DETAIL_seq'), ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_ID INT NOT NULL, DEVICE_ID INT NOT NULL,
DEVICE_MODEL VARCHAR(45) NULL, DEVICE_MODEL VARCHAR(45) NULL,
VENDOR VARCHAR(45) NULL, VENDOR VARCHAR(45) NULL,
@ -431,7 +422,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL,
PLUGGED_IN INT NULL, PLUGGED_IN INT NULL,
UPDATE_TIMESTAMP BIGINT NOT NULL, UPDATE_TIMESTAMP BIGINT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID) FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID) REFERENCES DM_DEVICE (ID)
@ -439,5 +429,3 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx ON DM_DEVICE_DETAIL (DEVICE_ID ASC);

Loading…
Cancel
Save