|
|
@ -8,20 +8,13 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
|
|
|
|
|
|
|
|
ID INTEGER auto_increment NOT NULL,
|
|
|
|
|
|
|
|
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
|
|
|
|
|
|
|
CERTIFICATE BLOB DEFAULT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
|
|
|
|
USERNAME VARCHAR(500) DEFAULT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_GROUP (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_GROUP (
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
|
|
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
|
|
|
STATUS VARCHAR(50) DEFAULT NULL,
|
|
|
|
|
|
|
|
DESCRIPTION TEXT DEFAULT NULL,
|
|
|
|
DESCRIPTION TEXT DEFAULT NULL,
|
|
|
|
|
|
|
|
STATUS VARCHAR(50) DEFAULT NULL,
|
|
|
|
|
|
|
|
DATE_OF_CREATE BIGINT DEFAULT NULL,
|
|
|
|
|
|
|
|
DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL,
|
|
|
|
OWNER VARCHAR(255) DEFAULT NULL,
|
|
|
|
OWNER VARCHAR(255) DEFAULT NULL,
|
|
|
|
PARENT_PATH VARCHAR(255) DEFAULT NULL,
|
|
|
|
PARENT_PATH VARCHAR(255) DEFAULT NULL,
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
@ -39,6 +32,15 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_GROUP_MAP (
|
|
|
|
REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
|
|
|
|
|
|
|
|
ID INTEGER auto_increment NOT NULL,
|
|
|
|
|
|
|
|
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
|
|
|
|
|
|
|
CERTIFICATE BLOB DEFAULT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
|
|
|
|
USERNAME VARCHAR(500) DEFAULT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE (
|
|
|
|
ID INTEGER auto_increment NOT NULL,
|
|
|
|
ID INTEGER auto_increment NOT NULL,
|
|
|
|
DESCRIPTION TEXT DEFAULT NULL,
|
|
|
|
DESCRIPTION TEXT DEFAULT NULL,
|
|
|
@ -90,13 +92,17 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
|
|
|
|
OPERATION_CODE VARCHAR(1000) NOT NULL,
|
|
|
|
OPERATION_CODE VARCHAR(1000) NOT NULL,
|
|
|
|
INITIATED_BY VARCHAR(100) NULL,
|
|
|
|
INITIATED_BY VARCHAR(100) NULL,
|
|
|
|
OPERATION_DETAILS BLOB DEFAULT NULL,
|
|
|
|
OPERATION_DETAILS BLOB DEFAULT NULL,
|
|
|
|
|
|
|
|
OPERATION_PROPERTIES BLOB DEFAULT NULL,
|
|
|
|
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_TYPE VARCHAR(300) NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL,
|
|
|
|
OWNER VARCHAR(255) NOT NULL,
|
|
|
|
OWNER VARCHAR(255) NOT NULL,
|
|
|
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
|
|
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
|
|
|
STATUS VARCHAR(50) NULL,
|
|
|
|
STATUS VARCHAR(50) NULL,
|
|
|
@ -109,6 +115,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
|
|
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
|
|
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
|
|
|
CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID)
|
|
|
|
CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS (
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
@ -122,6 +129,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS (
|
|
|
|
CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
|
|
|
CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES
|
|
|
|
DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING (
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
@ -191,8 +199,8 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY (
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
NAME VARCHAR(45) DEFAULT NULL ,
|
|
|
|
NAME VARCHAR(45) DEFAULT NULL ,
|
|
|
|
|
|
|
|
PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL,
|
|
|
|
DESCRIPTION VARCHAR(1000) NULL,
|
|
|
|
DESCRIPTION VARCHAR(1000) NULL,
|
|
|
|
PAYLOAD_VERSION VARCHAR (45) NULL,
|
|
|
|
|
|
|
|
TENANT_ID INT NOT NULL ,
|
|
|
|
TENANT_ID INT NOT NULL ,
|
|
|
|
PROFILE_ID INT NOT NULL ,
|
|
|
|
PROFILE_ID INT NOT NULL ,
|
|
|
|
OWNERSHIP_TYPE VARCHAR(45) NULL,
|
|
|
|
OWNERSHIP_TYPE VARCHAR(45) NULL,
|
|
|
@ -209,6 +217,21 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
ACTION_TYPE VARCHAR(45) NOT NULL,
|
|
|
|
|
|
|
|
CORRECTIVE_POLICY_ID INT DEFAULT NULL,
|
|
|
|
|
|
|
|
POLICY_ID INT NOT NULL,
|
|
|
|
|
|
|
|
FEATURE_ID INT DEFAULT NULL,
|
|
|
|
|
|
|
|
IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
|
|
|
|
|
|
|
|
FOREIGN KEY (POLICY_ID)
|
|
|
|
|
|
|
|
REFERENCES DM_POLICY (ID)
|
|
|
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
DEVICE_ID INT NOT NULL ,
|
|
|
|
DEVICE_ID INT NOT NULL ,
|
|
|
@ -255,21 +278,6 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
ACTION_TYPE VARCHAR(45) NOT NULL,
|
|
|
|
|
|
|
|
CORRECTIVE_POLICY_ID INT DEFAULT NULL,
|
|
|
|
|
|
|
|
POLICY_ID INT NOT NULL,
|
|
|
|
|
|
|
|
FEATURE_ID INT DEFAULT NULL,
|
|
|
|
|
|
|
|
IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
|
|
|
|
|
|
|
|
FOREIGN KEY (POLICY_ID)
|
|
|
|
|
|
|
|
REFERENCES DM_POLICY (ID)
|
|
|
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
ROLE_NAME VARCHAR(45) NOT NULL ,
|
|
|
|
ROLE_NAME VARCHAR(45) NOT NULL ,
|
|
|
@ -342,7 +350,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
|
|
|
|
POLICY_CRITERION_ID INT NOT NULL,
|
|
|
|
POLICY_CRITERION_ID INT NOT NULL,
|
|
|
|
PROP_KEY VARCHAR(45) NULL,
|
|
|
|
PROP_KEY VARCHAR(45) NULL,
|
|
|
|
PROP_VALUE VARCHAR(100) NULL,
|
|
|
|
PROP_VALUE VARCHAR(100) NULL,
|
|
|
|
CONTENT BLOB NULL,
|
|
|
|
CONTENT BLOB NULL COMMENT 'This is used to ',
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
|
|
|
|
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
|
|
|
|
FOREIGN KEY (POLICY_CRITERION_ID)
|
|
|
|
FOREIGN KEY (POLICY_CRITERION_ID)
|
|
|
@ -418,21 +426,11 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
|
|
|
|
|
|
|
|
|
|
|
|
-- POLICY RELATED TABLES FINISHED --
|
|
|
|
-- POLICY RELATED TABLES FINISHED --
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_APP_ICONS (
|
|
|
|
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
|
|
|
|
ICON_PATH VARCHAR(150) DEFAULT NULL,
|
|
|
|
|
|
|
|
PACKAGE_NAME VARCHAR(150) NOT NULL,
|
|
|
|
|
|
|
|
VERSION VARCHAR(50) DEFAULT '1.1.0',
|
|
|
|
|
|
|
|
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- NOTIFICATION TABLE --
|
|
|
|
-- NOTIFICATION TABLE --
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
|
|
|
|
NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_ID INTEGER NULL,
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
STATUS VARCHAR(10) NULL,
|
|
|
|
STATUS VARCHAR(10) NULL,
|
|
|
|
DESCRIPTION VARCHAR(1000) NULL,
|
|
|
|
DESCRIPTION VARCHAR(1000) NULL,
|
|
|
@ -462,8 +460,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX IDX_DM_DEVICE_INFO_DID_EID_KFIELD ON DM_DEVICE_INFO(DEVICE_ID, ENROLMENT_ID, KEY_FIELD);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
DEVICE_ID INT NULL,
|
|
|
|
DEVICE_ID INT NULL,
|
|
|
@ -494,6 +490,7 @@ 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 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 (
|
|
|
@ -529,27 +526,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX IDX_DM_DEVICE_DETAIL_DID_EID ON DM_DEVICE_DETAIL(DEVICE_ID, ENROLMENT_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_ID INT NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_ID_NAME VARCHAR(255) NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INT NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_TYPE_NAME VARCHAR(45) NOT NULL,
|
|
|
|
|
|
|
|
LATITUDE DOUBLE NULL,
|
|
|
|
|
|
|
|
LONGITUDE DOUBLE NULL,
|
|
|
|
|
|
|
|
SPEED FLOAT NULL,
|
|
|
|
|
|
|
|
HEADING FLOAT NULL,
|
|
|
|
|
|
|
|
TIMESTAMP BIGINT NOT NULL,
|
|
|
|
|
|
|
|
GEO_HASH VARCHAR(45) NULL,
|
|
|
|
|
|
|
|
DEVICE_OWNER VARCHAR(45) NULL,
|
|
|
|
|
|
|
|
DEVICE_ALTITUDE DOUBLE NULL,
|
|
|
|
|
|
|
|
DISTANCE DOUBLE NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
-- POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
@ -570,51 +546,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
|
|
|
|
);
|
|
|
|
);
|
|
|
|
-- END OF POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
-- END OF POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_PLATFORM (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
DEVICE_TYPE_ID INT NULL DEFAULT 0,
|
|
|
|
|
|
|
|
VERSION_NAME VARCHAR(100) NULL,
|
|
|
|
|
|
|
|
VERSION_STATUS VARCHAR(100) NULL DEFAULT 'ACTIVE',
|
|
|
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
|
|
|
CONSTRAINT DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING
|
|
|
|
|
|
|
|
FOREIGN KEY (DEVICE_TYPE_ID)
|
|
|
|
|
|
|
|
REFERENCES DM_DEVICE_TYPE (ID) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
|
|
|
|
CONSTRAINT device_type_version_uk
|
|
|
|
|
|
|
|
UNIQUE (
|
|
|
|
|
|
|
|
DEVICE_TYPE_ID,
|
|
|
|
|
|
|
|
VERSION_NAME
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- METADATA TABLE --
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_METADATA (
|
|
|
|
|
|
|
|
METADATA_ID INT AUTO_INCREMENT NOT NULL,
|
|
|
|
|
|
|
|
DATA_TYPE VARCHAR(16) NOT NULL,
|
|
|
|
|
|
|
|
METADATA_KEY VARCHAR(128) NOT NULL,
|
|
|
|
|
|
|
|
METADATA_VALUE VARCHAR(8000) NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (METADATA_ID),
|
|
|
|
|
|
|
|
CONSTRAINT METADATA_KEY_TENANT_ID UNIQUE (METADATA_KEY, TENANT_ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF METADATA TABLE --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DM_OTP_DATA TABLE --
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_OTP_DATA (
|
|
|
|
|
|
|
|
ID INT AUTO_INCREMENT NOT NULL,
|
|
|
|
|
|
|
|
OTP_TOKEN VARCHAR(100) NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INT NOT NULL,
|
|
|
|
|
|
|
|
USERNAME VARCHAR(500) DEFAULT NOT NULL,
|
|
|
|
|
|
|
|
EMAIL VARCHAR(100) NOT NULL,
|
|
|
|
|
|
|
|
EMAIL_TYPE VARCHAR(20) NOT NULL,
|
|
|
|
|
|
|
|
META_INFO VARCHAR(20000) NOT NULL,
|
|
|
|
|
|
|
|
CREATED_AT TIMESTAMP NOT NULL,
|
|
|
|
|
|
|
|
EXPIRY_TIME INT NOT NULL DEFAULT 3600,
|
|
|
|
|
|
|
|
IS_EXPIRED BOOLEAN DEFAULT false,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_OTP_DATA TABLE --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DASHBOARD RELATED VIEWS --
|
|
|
|
-- DASHBOARD RELATED VIEWS --
|
|
|
|
CREATE VIEW POLICY_COMPLIANCE_INFO AS
|
|
|
|
CREATE VIEW POLICY_COMPLIANCE_INFO AS
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
@ -670,171 +601,22 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND
|
|
|
|
DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID
|
|
|
|
DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID
|
|
|
|
ORDER BY TENANT_ID, DEVICE_ID;
|
|
|
|
ORDER BY TENANT_ID, DEVICE_ID;
|
|
|
|
|
|
|
|
|
|
|
|
-- END OF DASHBOARD RELATED VIEWS --
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
|
|
|
-- DM_GEOFENCE TABLE--
|
|
|
|
*
|
|
|
|
|
|
|
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_GEOFENCE (
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
* in compliance with the License.
|
|
|
|
FENCE_NAME VARCHAR(255) NOT NULL,
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
DESCRIPTION TEXT DEFAULT NULL,
|
|
|
|
*
|
|
|
|
LATITUDE DOUBLE DEFAULT NULL,
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
LONGITUDE DOUBLE DEFAULT NULL,
|
|
|
|
*
|
|
|
|
RADIUS DOUBLE DEFAULT NULL,
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
GEO_JSON TEXT DEFAULT NULL,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
FENCE_SHAPE VARCHAR(100) DEFAULT NULL,
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
CREATED_TIMESTAMP TIMESTAMP NOT NULL,
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
OWNER VARCHAR(255) NOT NULL,
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
* under the License.
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
*/
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- END OF DM_GEOFENCE TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DM_GEOFENCE_GROUP_MAPPING TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_GEOFENCE_GROUP_MAPPING (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
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 --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_EVENT (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
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--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_EVENT_GROUP_MAPPING (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
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--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
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--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DM_EXT_GROUP_MAPPING TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_EXT_GROUP_MAPPING (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
TRACCAR_GROUP_ID INT DEFAULT 0,
|
|
|
|
|
|
|
|
GROUP_ID INT NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INT NOT NULL,
|
|
|
|
|
|
|
|
STATUS INT DEFAULT 0,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_EXT_GROUP_MAPPING TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- END OF DM_EXT_DEVICE_MAPPING TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
TRACCAR_DEVICE_ID INT DEFAULT 0,
|
|
|
|
|
|
|
|
DEVICE_ID INT NOT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INT NOT NULL,
|
|
|
|
|
|
|
|
STATUS INT DEFAULT 0,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_EXT_DEVICE_MAPPING TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- END OF DM_EXT_PERMISSION_MAPPING TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING (
|
|
|
|
|
|
|
|
TRACCAR_DEVICE_ID INT DEFAULT 0,
|
|
|
|
|
|
|
|
TRACCAR_USER_ID INT DEFAULT 0
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_EXT_PERMISSION_MAPPING TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DYNAMIC TASK TABLES--
|
|
|
|
-- END OF DASHBOARD RELATED VIEWS --
|
|
|
|
CREATE TABLE IF NOT EXISTS DYNAMIC_TASK (
|
|
|
|
|
|
|
|
DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL,
|
|
|
|
|
|
|
|
NAME VARCHAR(300) DEFAULT NULL ,
|
|
|
|
|
|
|
|
CRON VARCHAR(8000) DEFAULT NULL,
|
|
|
|
|
|
|
|
IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
|
|
|
TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
|
|
|
|
PRIMARY KEY (DYNAMIC_TASK_ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
|
|
|
|
|
|
|
|
DYNAMIC_TASK_ID INTEGER NOT NULL,
|
|
|
|
|
|
|
|
PROPERTY_NAME VARCHAR(100) DEFAULT 0,
|
|
|
|
|
|
|
|
PROPERTY_VALUE VARCHAR(100) DEFAULT NULL,
|
|
|
|
|
|
|
|
TENANT_ID VARCHAR(100),
|
|
|
|
|
|
|
|
PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID),
|
|
|
|
|
|
|
|
CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES
|
|
|
|
|
|
|
|
DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DYNAMIC TASK TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DM_DEVICE_SUB_TYPE TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
|
|
|
|
|
|
|
|
TENANT_ID INT DEFAULT 0,
|
|
|
|
|
|
|
|
SUB_TYPE_ID VARCHAR(45) NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_TYPE VARCHAR(25) NOT NULL,
|
|
|
|
|
|
|
|
SUB_TYPE_NAME VARCHAR(45) NOT NULL,
|
|
|
|
|
|
|
|
TYPE_DEFINITION TEXT NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_DEVICE_SUB_TYPE TABLE--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DM_TRACCAR_UNSYNCED_DEVICES TABLE --
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES (
|
|
|
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
DEVICE_NAME VARCHAR(100) NOT NULL,
|
|
|
|
|
|
|
|
IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE,
|
|
|
|
|
|
|
|
TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL,
|
|
|
|
|
|
|
|
TRACCAR_USENAME VARCHAR(100) NULL,
|
|
|
|
|
|
|
|
STATUS VARCHAR(100) NULL,
|
|
|
|
|
|
|
|
TENANT_ID INTEGER DEFAULT 0,
|
|
|
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- SUB_OPERATION_TEMPLATE TABLE--
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE (
|
|
|
|
|
|
|
|
SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
|
|
|
OPERATION_DEFINITION TEXT NOT NULL,
|
|
|
|
|
|
|
|
OPERATION_CODE VARCHAR(100) NOT NULL,
|
|
|
|
|
|
|
|
SUB_TYPE_ID INT NOT NULL,
|
|
|
|
|
|
|
|
DEVICE_TYPE VARCHAR(25) NOT NULL,
|
|
|
|
|
|
|
|
CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
|
|
|
|
UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID),
|
|
|
|
|
|
|
|
CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE),
|
|
|
|
|
|
|
|
-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE),
|
|
|
|
|
|
|
|
CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- END OF SUB_OPERATION_TEMPLATE TABLE--
|
|
|
|
|
|
|
|