Fix dbscripts for device enrolment

pull/113/head
prathabanKavin 2 years ago
parent 03125e3dca
commit add1db9948

@ -730,7 +730,7 @@ ORDER BY TENANT_ID, DEVICE_ID');
-- END OF DASHBOARD RELATED VIEWS -- -- END OF DASHBOARD RELATED VIEWS --
-- DM_GEOFENCE TABLE-- -- DM_GEOFENCE TABLE--
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_GEOFENCE]') AND TYPE IN (N'U'))
CREATE TABLE DM_GEOFENCE ( CREATE TABLE DM_GEOFENCE (
ID INT IDENTITY NOT NULL, ID INT IDENTITY NOT NULL,
FENCE_NAME VARCHAR(255) NOT NULL, FENCE_NAME VARCHAR(255) NOT NULL,
@ -748,6 +748,83 @@ CREATE TABLE DM_GEOFENCE (
-- END OF DM_GEOFENCE TABLE-- -- END OF DM_GEOFENCE TABLE--
-- DM_GEOFENCE_GROUP_MAPPING TABLE--
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_GEOFENCE_GROUP_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE DM_GEOFENCE_GROUP_MAPPING (
ID INT IDENTITY NOT NULL,
FENCE_ID INT NOT NULL,
GROUP_ID INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_dm_geofence_group_mapping_geofence
FOREIGN KEY (FENCE_ID)
REFERENCES DM_GEOFENCE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_dm_geofence_group_mapping_group
FOREIGN KEY (GROUP_ID)
REFERENCES DM_GROUP (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
-- END OF DM_GEOFENCE_GROUP_MAPPING TABLE--
-- DM_DEVICE_EVENT TABLE --
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_EVENT]') AND TYPE IN (N'U'))
CREATE TABLE DM_DEVICE_EVENT (
ID INT IDENTITY NOT NULL,
EVENT_SOURCE VARCHAR(100) NOT NULL,
EVENT_LOGIC VARCHAR(100) NOT NULL,
ACTIONS TEXT DEFAULT NULL,
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (ID)
);
-- END OF DM_DEVICE_EVENT TABLE --
-- DM_DEVICE_EVENT_GROUP_MAPPING TABLE--
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_EVENT_GROUP_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE DM_DEVICE_EVENT_GROUP_MAPPING (
ID INT IDENTITY NOT NULL,
EVENT_ID INT NOT NULL,
GROUP_ID INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_dm_event_group_mapping_event
FOREIGN KEY (EVENT_ID)
REFERENCES DM_DEVICE_EVENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_dm_event_group_mapping_group
FOREIGN KEY (GROUP_ID)
REFERENCES DM_GROUP (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
-- END OF DM_DEVICE_EVENT_GROUP_MAPPING TABLE--
-- DM_GEOFENCE_GROUP_MAPPING TABLE--
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_GEOFENCE_EVENT_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE DM_GEOFENCE_EVENT_MAPPING (
ID INT IDENTITY NOT NULL,
FENCE_ID INT NOT NULL,
EVENT_ID INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk_dm_geofence_event_mapping_geofence
FOREIGN KEY (FENCE_ID)
REFERENCES DM_GEOFENCE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_dm_geofence_event_mapping_event
FOREIGN KEY (EVENT_ID)
REFERENCES DM_DEVICE_EVENT (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
-- END OF DM_GEOFENCE_GROUP_MAPPING TABLE--
-- DYNAMIC TASK TABLES-- -- DYNAMIC TASK TABLES--
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DYNAMIC_TASK]') AND TYPE IN (N'U')) IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DYNAMIC_TASK]') AND TYPE IN (N'U'))
CREATE TABLE DYNAMIC_TASK ( CREATE TABLE DYNAMIC_TASK (

Loading…
Cancel
Save