|
|
|
@ -69,6 +69,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_MAPPING (
|
|
|
|
|
|
|
|
|
|
--- POLICY RELATED TABLES ----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
PROFILE_NAME VARCHAR(45) NOT NULL ,
|
|
|
|
@ -77,114 +80,184 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
|
|
|
|
CREATED_TIME DATETIME NOT NULL ,
|
|
|
|
|
UPDATED_TIME DATETIME NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT DM_PROFILE_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE_ID ) REFERENCES DM_DEVICE_TYPE (ID )
|
|
|
|
|
CONSTRAINT DM_PROFILE_DEVICE_TYPE
|
|
|
|
|
FOREIGN KEY (DEVICE_TYPE_ID )
|
|
|
|
|
REFERENCES DM_DEVICE_TYPE (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY (
|
|
|
|
|
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
NAME VARCHAR(45) NULL DEFAULT NULL ,
|
|
|
|
|
TENANT_ID INT(11) NOT NULL ,
|
|
|
|
|
PROFILE_ID INT(11) NOT NULL ,
|
|
|
|
|
COMPLIANCE VARCHAR(100) NULL,
|
|
|
|
|
PRIORITY INT NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) REFERENCES DM_PROFILE (ID )
|
|
|
|
|
CONSTRAINT FK_DM_PROFILE_DM_POLICY
|
|
|
|
|
FOREIGN KEY (PROFILE_ID )
|
|
|
|
|
REFERENCES DM_PROFILE (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
|
|
|
|
|
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
DEVICE_ID INT(11) NOT NULL ,
|
|
|
|
|
POLICY_ID INT(11) NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
CONSTRAINT FK_POLICY_DEVICE_POLICY
|
|
|
|
|
FOREIGN KEY (POLICY_ID )
|
|
|
|
|
REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
|
CONSTRAINT FK_DEVICE_DEVICE_POLICY FOREIGN KEY (DEVICE_ID ) REFERENCES DM_DEVICE (ID )
|
|
|
|
|
CONSTRAINT FK_DEVICE_DEVICE_POLICY
|
|
|
|
|
FOREIGN KEY (DEVICE_ID )
|
|
|
|
|
REFERENCES DM_DEVICE (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
|
|
|
|
ID INT(11) NOT NULL ,
|
|
|
|
|
DEVICE_TYPE_ID INT(11) NOT NULL ,
|
|
|
|
|
POLICY_ID INT(11) NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
CONSTRAINT FK_DEVICE_TYPE_POLICY
|
|
|
|
|
FOREIGN KEY (POLICY_ID )
|
|
|
|
|
REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
|
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE_ID ) REFERENCES DM_DEVICE_TYPE (ID )
|
|
|
|
|
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE
|
|
|
|
|
FOREIGN KEY (DEVICE_TYPE_ID )
|
|
|
|
|
REFERENCES DM_DEVICE_TYPE (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
|
|
|
|
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
|
|
|
|
PROFILE_ID INT(11) NOT NULL,
|
|
|
|
|
FEATURE_CODE VARCHAR(10) NOT NULL,
|
|
|
|
|
FEATURE_CODE VARCHAR(30) NOT NULL,
|
|
|
|
|
DEVICE_TYPE_ID INT NOT NULL,
|
|
|
|
|
CONTENT BLOB NULL DEFAULT NULL,
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES FOREIGN KEY (PROFILE_ID) REFERENCES DM_PROFILE (ID)
|
|
|
|
|
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
|
|
|
|
|
FOREIGN KEY (PROFILE_ID)
|
|
|
|
|
REFERENCES DM_PROFILE (ID)
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
|
|
|
|
|
ID INT(11) NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
ROLE_NAME VARCHAR(45) NOT NULL ,
|
|
|
|
|
POLICY_ID INT(11) NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
CONSTRAINT FK_ROLE_POLICY_POLICY
|
|
|
|
|
FOREIGN KEY (POLICY_ID )
|
|
|
|
|
REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_LOCATION (
|
|
|
|
|
LATITUDE VARCHAR(45) NOT NULL ,
|
|
|
|
|
LONGITUDE VARCHAR(45) NOT NULL ,
|
|
|
|
|
POLICY_ID INT(11) NOT NULL ,
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DM_LOCATION FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
POLICY_ID INT NOT NULL ,
|
|
|
|
|
USERNAME VARCHAR(45) NOT NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT DM_POLICY_USER_POLICY
|
|
|
|
|
FOREIGN KEY (POLICY_ID )
|
|
|
|
|
REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_TIME (
|
|
|
|
|
STARTING_TIME DATETIME NOT NULL ,
|
|
|
|
|
ENDING_TIME DATETIME NOT NULL ,
|
|
|
|
|
POLICY_ID INT(11) NOT NULL ,
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DM_TIME FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT ,
|
|
|
|
|
DEVICE_ID INT NOT NULL ,
|
|
|
|
|
POLICY_ID INT NOT NULL ,
|
|
|
|
|
POLICY_CONTENT BLOB NULL ,
|
|
|
|
|
APPLIED TINYINT(1) NULL ,
|
|
|
|
|
CREATED_TIME TIMESTAMP NULL ,
|
|
|
|
|
UPDATED_TIME TIMESTAMP NULL ,
|
|
|
|
|
APPLIED_TIME TIMESTAMP NULL ,
|
|
|
|
|
PRIMARY KEY (ID) ,
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED
|
|
|
|
|
FOREIGN KEY (DEVICE_ID )
|
|
|
|
|
REFERENCES DM_DEVICE (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
|
CONSTRAINT FK_DM_POLICY_DEVICE_APPLIED_POLICY
|
|
|
|
|
FOREIGN KEY (POLICY_ID )
|
|
|
|
|
REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_DATE (
|
|
|
|
|
START_DATE DATE NOT NULL ,
|
|
|
|
|
END_DATE DATE NOT NULL ,
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_CRITERIA (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
TENANT_ID INT NOT NULL,
|
|
|
|
|
NAME VARCHAR(50) NULL,
|
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
CRITERIA_ID INT NOT NULL,
|
|
|
|
|
POLICY_ID INT NOT NULL,
|
|
|
|
|
CONSTRAINT DM_DATE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
CONSTRAINT FK_CRITERIA_POLICY_CRITERIA
|
|
|
|
|
FOREIGN KEY (CRITERIA_ID)
|
|
|
|
|
REFERENCES DM_CRITERIA (ID)
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION,
|
|
|
|
|
CONSTRAINT FK_POLICY_POLICY_CRITERIA
|
|
|
|
|
FOREIGN KEY (POLICY_ID)
|
|
|
|
|
REFERENCES DM_POLICY (ID)
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
|
|
|
|
|
ID INT NOT NULL AUTO_INCREMENT,
|
|
|
|
|
POLICY_ID INT NOT NULL ,
|
|
|
|
|
USERNAME VARCHAR(45) NOT NULL ,
|
|
|
|
|
POLICY_CRITERION_ID INT NOT NULL,
|
|
|
|
|
PROP_KEY VARCHAR(45) NULL,
|
|
|
|
|
PROP_VALUE VARCHAR(100) NULL,
|
|
|
|
|
CONTENT BLOB NULL COMMENT 'This is used to ',
|
|
|
|
|
PRIMARY KEY (ID),
|
|
|
|
|
CONSTRAINT DM_POLICY_USER_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID )
|
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
|
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
|
|
|
|
|
FOREIGN KEY (POLICY_CRITERION_ID)
|
|
|
|
|
REFERENCES DM_POLICY_CRITERIA (ID)
|
|
|
|
|
ON DELETE CASCADE
|
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|