|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_TYPE]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_TYPE (
|
|
|
|
CREATE TABLE DM_DEVICE_TYPE (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
NAME VARCHAR(300) DEFAULT NULL,
|
|
|
|
NAME VARCHAR(300) DEFAULT NULL,
|
|
|
@ -7,8 +8,10 @@ CREATE TABLE DM_DEVICE_TYPE (
|
|
|
|
CONSTRAINT DEVICE_TYPE_NAME UNIQUE(NAME)
|
|
|
|
CONSTRAINT DEVICE_TYPE_NAME UNIQUE(NAME)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE'))
|
|
|
|
CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME);
|
|
|
|
CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE (
|
|
|
|
CREATE TABLE DM_DEVICE (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DESCRIPTION VARCHAR(MAX) DEFAULT NULL,
|
|
|
|
DESCRIPTION VARCHAR(MAX) DEFAULT NULL,
|
|
|
@ -22,8 +25,10 @@ CREATE TABLE DM_DEVICE (
|
|
|
|
REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DM_DEVICE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE'))
|
|
|
|
CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID);
|
|
|
|
CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_OPERATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_OPERATION (
|
|
|
|
CREATE TABLE DM_OPERATION (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
TYPE VARCHAR(20) NOT NULL,
|
|
|
|
TYPE VARCHAR(20) NOT NULL,
|
|
|
@ -33,6 +38,7 @@ CREATE TABLE DM_OPERATION (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_CONFIG_OPERATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_CONFIG_OPERATION (
|
|
|
|
CREATE TABLE DM_CONFIG_OPERATION (
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_CONFIG VARBINARY(MAX) DEFAULT NULL,
|
|
|
|
OPERATION_CONFIG VARBINARY(MAX) DEFAULT NULL,
|
|
|
@ -41,6 +47,7 @@ CREATE TABLE DM_CONFIG_OPERATION (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_COMMAND_OPERATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_COMMAND_OPERATION (
|
|
|
|
CREATE TABLE DM_COMMAND_OPERATION (
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
ENABLED BIT NOT NULL DEFAULT 0,
|
|
|
|
ENABLED BIT NOT NULL DEFAULT 0,
|
|
|
@ -49,6 +56,7 @@ CREATE TABLE DM_COMMAND_OPERATION (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_OPERATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_OPERATION (
|
|
|
|
CREATE TABLE DM_POLICY_OPERATION (
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
|
|
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
|
@ -58,6 +66,7 @@ CREATE TABLE DM_POLICY_OPERATION (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE_OPERATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_PROFILE_OPERATION (
|
|
|
|
CREATE TABLE DM_PROFILE_OPERATION (
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
OPERATION_ID INTEGER NOT NULL,
|
|
|
|
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
|
|
ENABLED INTEGER NOT NULL DEFAULT 0,
|
|
|
@ -67,6 +76,7 @@ CREATE TABLE DM_PROFILE_OPERATION (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ENROLMENT]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_ENROLMENT (
|
|
|
|
CREATE TABLE DM_ENROLMENT (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
@ -81,9 +91,12 @@ CREATE TABLE DM_ENROLMENT (
|
|
|
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_FK_DEVICE_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT'))
|
|
|
|
CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID);
|
|
|
|
CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID);
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_DEVICE_ID_TENANT_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT'))
|
|
|
|
CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID);
|
|
|
|
CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ENROLMENT_OP_MAPPING]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_ENROLMENT_OP_MAPPING (
|
|
|
|
CREATE TABLE DM_ENROLMENT_OP_MAPPING (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
@ -98,10 +111,14 @@ CREATE TABLE DM_ENROLMENT_OP_MAPPING (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_OP_MAPPING' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING'))
|
|
|
|
CREATE INDEX IDX_ENROLMENT_OP_MAPPING ON DM_ENROLMENT_OP_MAPPING (UPDATED_TIMESTAMP);
|
|
|
|
CREATE INDEX IDX_ENROLMENT_OP_MAPPING ON DM_ENROLMENT_OP_MAPPING (UPDATED_TIMESTAMP);
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_EN_OP_MAPPING_EN_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING'))
|
|
|
|
CREATE INDEX IDX_EN_OP_MAPPING_EN_ID ON DM_ENROLMENT_OP_MAPPING(ENROLMENT_ID);
|
|
|
|
CREATE INDEX IDX_EN_OP_MAPPING_EN_ID ON DM_ENROLMENT_OP_MAPPING(ENROLMENT_ID);
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_EN_OP_MAPPING_OP_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING'))
|
|
|
|
CREATE INDEX IDX_EN_OP_MAPPING_OP_ID ON DM_ENROLMENT_OP_MAPPING(OPERATION_ID);
|
|
|
|
CREATE INDEX IDX_EN_OP_MAPPING_OP_ID ON DM_ENROLMENT_OP_MAPPING(OPERATION_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_OPERATION_RESPONSE]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_OPERATION_RESPONSE (
|
|
|
|
CREATE TABLE DM_DEVICE_OPERATION_RESPONSE (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
|
ENROLMENT_ID INTEGER NOT NULL,
|
|
|
@ -115,10 +132,12 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE (
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENID_OPID' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_OPERATION_RESPONSE'))
|
|
|
|
CREATE INDEX IDX_ENID_OPID ON DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID);
|
|
|
|
CREATE INDEX IDX_ENID_OPID ON DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID);
|
|
|
|
|
|
|
|
|
|
|
|
-- POLICY RELATED TABLES --
|
|
|
|
-- POLICY RELATED TABLES --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_PROFILE (
|
|
|
|
CREATE TABLE DM_PROFILE (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
PROFILE_NAME VARCHAR(45) NOT NULL ,
|
|
|
|
PROFILE_NAME VARCHAR(45) NOT NULL ,
|
|
|
@ -131,6 +150,7 @@ CREATE TABLE DM_PROFILE (
|
|
|
|
DM_DEVICE_TYPE (NAME) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
DM_DEVICE_TYPE (NAME) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY (
|
|
|
|
CREATE TABLE DM_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
NAME VARCHAR(45) DEFAULT NULL ,
|
|
|
|
NAME VARCHAR(45) DEFAULT NULL ,
|
|
|
@ -147,6 +167,7 @@ CREATE TABLE DM_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_POLICY (
|
|
|
|
CREATE TABLE DM_DEVICE_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL ,
|
|
|
|
DEVICE_ID INTEGER NOT NULL ,
|
|
|
@ -160,6 +181,7 @@ CREATE TABLE DM_DEVICE_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_TYPE_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_TYPE_POLICY (
|
|
|
|
CREATE TABLE DM_DEVICE_TYPE_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_TYPE_ID INTEGER NOT NULL ,
|
|
|
|
DEVICE_TYPE_ID INTEGER NOT NULL ,
|
|
|
@ -171,6 +193,7 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE_FEATURES]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_PROFILE_FEATURES (
|
|
|
|
CREATE TABLE DM_PROFILE_FEATURES (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
PROFILE_ID INTEGER NOT NULL,
|
|
|
|
PROFILE_ID INTEGER NOT NULL,
|
|
|
@ -183,6 +206,7 @@ CREATE TABLE DM_PROFILE_FEATURES (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ROLE_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_ROLE_POLICY (
|
|
|
|
CREATE TABLE DM_ROLE_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ROLE_NAME VARCHAR(45) NOT NULL ,
|
|
|
|
ROLE_NAME VARCHAR(45) NOT NULL ,
|
|
|
@ -192,6 +216,7 @@ CREATE TABLE DM_ROLE_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_USER_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_USER_POLICY (
|
|
|
|
CREATE TABLE DM_USER_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
POLICY_ID INTEGER NOT NULL ,
|
|
|
|
POLICY_ID INTEGER NOT NULL ,
|
|
|
@ -201,6 +226,7 @@ CREATE TABLE DM_USER_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY_APPLIED]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_POLICY_APPLIED (
|
|
|
|
CREATE TABLE DM_DEVICE_POLICY_APPLIED (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL ,
|
|
|
|
DEVICE_ID INTEGER NOT NULL ,
|
|
|
@ -217,6 +243,7 @@ CREATE TABLE DM_USER_POLICY (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_CRITERIA]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_CRITERIA (
|
|
|
|
CREATE TABLE DM_CRITERIA (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
|
TENANT_ID INTEGER NOT NULL,
|
|
|
@ -224,6 +251,7 @@ CREATE TABLE DM_CRITERIA (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CRITERIA]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_CRITERIA (
|
|
|
|
CREATE TABLE DM_POLICY_CRITERIA (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
CRITERIA_ID INTEGER NOT NULL,
|
|
|
|
CRITERIA_ID INTEGER NOT NULL,
|
|
|
@ -235,6 +263,7 @@ CREATE TABLE DM_POLICY_CRITERIA (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CRITERIA_PROPERTIES]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES (
|
|
|
|
CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
POLICY_CRITERION_ID INTEGER NOT NULL,
|
|
|
|
POLICY_CRITERION_ID INTEGER NOT NULL,
|
|
|
@ -246,6 +275,7 @@ CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES (
|
|
|
|
ON DELETE CASCADE ON UPDATE NO ACTION
|
|
|
|
ON DELETE CASCADE ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_COMPLIANCE_STATUS]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_COMPLIANCE_STATUS (
|
|
|
|
CREATE TABLE DM_POLICY_COMPLIANCE_STATUS (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
@ -260,6 +290,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CHANGE_MGT]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_CHANGE_MGT (
|
|
|
|
CREATE TABLE DM_POLICY_CHANGE_MGT (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
POLICY_ID INTEGER NOT NULL,
|
|
|
|
POLICY_ID INTEGER NOT NULL,
|
|
|
@ -268,6 +299,7 @@ CREATE TABLE DM_POLICY_CHANGE_MGT (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_COMPLIANCE_FEATURES]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES (
|
|
|
|
CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
COMPLIANCE_STATUS_ID INTEGER NOT NULL,
|
|
|
|
COMPLIANCE_STATUS_ID INTEGER NOT NULL,
|
|
|
@ -279,6 +311,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES (
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_APPLICATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_APPLICATION (
|
|
|
|
CREATE TABLE DM_APPLICATION (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
NAME VARCHAR(150) NOT NULL,
|
|
|
|
NAME VARCHAR(150) NOT NULL,
|
|
|
@ -296,6 +329,7 @@ CREATE TABLE DM_APPLICATION (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_APPLICATION_MAPPING]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
|
|
|
CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
@ -312,7 +346,7 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- DEVICE GROUP TABLES --
|
|
|
|
-- DEVICE GROUP TABLES --
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_GROUP]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_GROUP (
|
|
|
|
CREATE TABLE DM_GROUP (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
|
|
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
|
|
@ -324,6 +358,7 @@ CREATE TABLE DM_GROUP (
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
PRIMARY KEY (ID)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_MAP]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_GROUP_MAP (
|
|
|
|
CREATE TABLE DM_DEVICE_GROUP_MAP (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER DEFAULT NULL,
|
|
|
|
DEVICE_ID INTEGER DEFAULT NULL,
|
|
|
@ -339,7 +374,7 @@ CREATE TABLE DM_DEVICE_GROUP_MAP (
|
|
|
|
-- END OF DEVICE GROUP TABLES --
|
|
|
|
-- END OF DEVICE GROUP TABLES --
|
|
|
|
|
|
|
|
|
|
|
|
-- POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
-- POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_POLICY]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_GROUP_POLICY (
|
|
|
|
CREATE TABLE DM_DEVICE_GROUP_POLICY (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_GROUP_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_GROUP_ID INTEGER NOT NULL,
|
|
|
@ -361,6 +396,7 @@ CREATE TABLE DM_DEVICE_GROUP_POLICY (
|
|
|
|
-- END OF POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
-- END OF POLICY AND DEVICE GROUP MAPPING --
|
|
|
|
|
|
|
|
|
|
|
|
-- NOTIFICATION TABLE --
|
|
|
|
-- NOTIFICATION TABLE --
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_NOTIFICATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_NOTIFICATION (
|
|
|
|
CREATE TABLE DM_NOTIFICATION (
|
|
|
|
NOTIFICATION_ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
NOTIFICATION_ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
@ -376,6 +412,7 @@ CREATE TABLE DM_NOTIFICATION (
|
|
|
|
);
|
|
|
|
);
|
|
|
|
-- NOTIFICATION TABLE END --
|
|
|
|
-- NOTIFICATION TABLE END --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_INFO]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_INFO (
|
|
|
|
CREATE TABLE DM_DEVICE_INFO (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NULL,
|
|
|
|
DEVICE_ID INTEGER NULL,
|
|
|
@ -387,6 +424,7 @@ CREATE TABLE DM_DEVICE_INFO (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_LOCATION]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_LOCATION (
|
|
|
|
CREATE TABLE DM_DEVICE_LOCATION (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NULL,
|
|
|
|
DEVICE_ID INTEGER NULL,
|
|
|
@ -408,6 +446,7 @@ CREATE TABLE DM_DEVICE_LOCATION (
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_DETAIL]') AND TYPE IN (N'U'))
|
|
|
|
CREATE TABLE DM_DEVICE_DETAIL (
|
|
|
|
CREATE TABLE DM_DEVICE_DETAIL (
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
|
DEVICE_ID INTEGER NOT NULL,
|
|
|
@ -438,6 +477,7 @@ CREATE TABLE DM_DEVICE_DETAIL (
|
|
|
|
|
|
|
|
|
|
|
|
-- DASHBOARD RELATED VIEWS --
|
|
|
|
-- DASHBOARD RELATED VIEWS --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.VIEWS WHERE NAME = 'POLICY_COMPLIANCE_INFO')
|
|
|
|
exec('CREATE VIEW POLICY_COMPLIANCE_INFO AS
|
|
|
|
exec('CREATE VIEW POLICY_COMPLIANCE_INFO AS
|
|
|
|
SELECT TOP 100 PERCENT
|
|
|
|
SELECT TOP 100 PERCENT
|
|
|
|
DEVICE_INFO.DEVICE_ID,
|
|
|
|
DEVICE_INFO.DEVICE_ID,
|
|
|
@ -469,6 +509,7 @@ DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO
|
|
|
|
ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID
|
|
|
|
ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID
|
|
|
|
ORDER BY DEVICE_INFO.DEVICE_ID');
|
|
|
|
ORDER BY DEVICE_INFO.DEVICE_ID');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF NOT EXISTS (SELECT * FROM SYS.VIEWS WHERE NAME = 'CREATE VIEW FEATURE_NON_COMPLIANCE_INFO')
|
|
|
|
exec('CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS
|
|
|
|
exec('CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS
|
|
|
|
SELECT TOP 100 PERCENT
|
|
|
|
SELECT TOP 100 PERCENT
|
|
|
|
DM_DEVICE.ID AS DEVICE_ID,
|
|
|
|
DM_DEVICE.ID AS DEVICE_ID,
|
|
|
|