Refactored mysql DB Script

revert-70aa11f8
Dileesha Rajapakse 9 years ago
parent d061f908a8
commit b55c5bc793

@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
ID INT auto_increment NOT NULL, ID INT auto_increment NOT NULL,
NAME VARCHAR(300) DEFAULT NULL, NAME VARCHAR(300) DEFAULT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE TABLE IF NOT EXISTS DM_DEVICE (
@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE (
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
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
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_OPERATION (
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
RECEIVED_TIMESTAMP TIMESTAMP NULL, RECEIVED_TIMESTAMP TIMESTAMP NULL,
OPERATION_CODE VARCHAR(1000) NOT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION ( CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION ( CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION ( CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION ( CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
@ -63,7 +63,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
PRIMARY KEY (OPERATION_ID), PRIMARY KEY (OPERATION_ID),
CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
@ -78,7 +78,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OPERATION_MAPPING ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OPERATION_MAPPING (
@ -91,7 +91,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OPERATION_MAPPING (
DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE (
@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE (
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_device_operation_response_operation FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_device_operation_response_operation FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
-- POLICY RELATED TABLES --- -- POLICY RELATED TABLES ---
@ -121,7 +121,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
REFERENCES DM_DEVICE_TYPE (ID ) REFERENCES DM_DEVICE_TYPE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY ( CREATE TABLE IF NOT EXISTS DM_POLICY (
@ -141,7 +141,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
REFERENCES DM_PROFILE (ID ) REFERENCES DM_PROFILE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
@ -161,7 +161,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
REFERENCES DM_DEVICE (ID ) REFERENCES DM_DEVICE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
@ -179,7 +179,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
REFERENCES DM_DEVICE_TYPE (ID ) REFERENCES DM_DEVICE_TYPE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
@ -195,7 +195,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
REFERENCES DM_PROFILE (ID) REFERENCES DM_PROFILE (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
@ -208,7 +208,7 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
REFERENCES DM_POLICY (ID ) REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
@ -221,7 +221,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
REFERENCES DM_POLICY (ID ) REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
@ -246,7 +246,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
REFERENCES DM_POLICY (ID ) REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_CRITERIA (
@ -254,7 +254,7 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA (
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
NAME VARCHAR(50) NULL, NAME VARCHAR(50) NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
@ -272,7 +272,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
REFERENCES DM_POLICY (ID) REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
@ -287,7 +287,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
REFERENCES DM_POLICY_CRITERIA (ID) REFERENCES DM_POLICY_CRITERIA (ID)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
@ -308,7 +308,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
REFERENCES DM_POLICY (ID) REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
@ -317,7 +317,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
DEVICE_TYPE_ID INT NOT NULL, DEVICE_TYPE_ID INT NOT NULL,
TENANT_ID INT(11) NOT NULL, TENANT_ID INT(11) NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
@ -332,7 +332,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
@ -347,7 +347,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_APPLICATION ( CREATE TABLE IF NOT EXISTS DM_APPLICATION (
@ -363,7 +363,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
APP_PROPERTIES BLOB NULL, APP_PROPERTIES BLOB NULL,
TENANT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
@ -376,7 +376,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES
DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
-- POLICY RELATED TABLES FINISHED -- -- POLICY RELATED TABLES FINISHED --
@ -393,6 +393,6 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
); )ENGINE = InnoDB;
-- NOTIFICATION TABLE END -- -- NOTIFICATION TABLE END --

Loading…
Cancel
Save