fixing sql scripts to support multi tenancy

4.x.x
Vishanth 8 years ago
parent 2206e258d1
commit f45528147c

@ -192,8 +192,8 @@ CREATE TABLE DM_PROFILE (
CREATED_TIME DATETIME NOT NULL , CREATED_TIME DATETIME NOT NULL ,
UPDATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT DM_PROFILE_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE) REFERENCES CONSTRAINT DM_PROFILE_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE, TENANT_ID) REFERENCES
DM_DEVICE_TYPE (NAME) ON DELETE NO ACTION ON UPDATE NO ACTION DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_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]') AND TYPE IN (N'U')) IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY]') AND TYPE IN (N'U'))
@ -234,8 +234,6 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY (
POLICY_ID INTEGER NOT NULL , POLICY_ID INTEGER NOT NULL ,
PRIMARY KEY (ID) , 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)
ON DELETE NO ACTION ON UPDATE NO ACTION ON DELETE NO ACTION ON UPDATE NO ACTION
); );

@ -170,8 +170,8 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
UPDATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT DM_PROFILE_DEVICE_TYPE CONSTRAINT DM_PROFILE_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE) FOREIGN KEY (DEVICE_TYPE, TENANT_ID)
REFERENCES DM_DEVICE_TYPE (NAME) REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
)ENGINE = InnoDB; )ENGINE = InnoDB;
@ -226,11 +226,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
FOREIGN KEY (POLICY_ID ) FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID ) REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE )
REFERENCES DM_DEVICE_TYPE (NAME )
ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
)ENGINE = InnoDB; )ENGINE = InnoDB;

@ -270,8 +270,8 @@ CREATE TABLE DM_PROFILE (
UPDATED_TIME TIMESTAMP(0) NOT NULL , UPDATED_TIME TIMESTAMP(0) NOT NULL ,
CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) , CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) ,
CONSTRAINT DM_PROFILE_DEVICE_TYPE CONSTRAINT DM_PROFILE_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE ) FOREIGN KEY (DEVICE_TYPE, TENANT_ID)
REFERENCES DM_DEVICE_TYPE (NAME ) REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID)
) )
/ /
-- Generate ID using sequence and trigger -- Generate ID using sequence and trigger
@ -358,10 +358,7 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY (
CONSTRAINT PK_DEV_TYPE_POLICY PRIMARY KEY (ID) , CONSTRAINT PK_DEV_TYPE_POLICY PRIMARY KEY (ID) ,
CONSTRAINT FK_DEV_TYPE_POLICY CONSTRAINT FK_DEV_TYPE_POLICY
FOREIGN KEY (POLICY_ID ) FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID ), REFERENCES DM_POLICY (ID )
CONSTRAINT FK_DEV_TYPE_POLICY_DEV_TYPE
FOREIGN KEY (DEVICE_TYPE )
REFERENCES DM_DEVICE_TYPE (NAME )
) )
/ /

@ -150,8 +150,8 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
CREATED_TIME TIMESTAMP NOT NULL , CREATED_TIME TIMESTAMP NOT NULL ,
UPDATED_TIME TIMESTAMP NOT NULL , UPDATED_TIME TIMESTAMP NOT NULL ,
CONSTRAINT DM_PROFILE_DEVICE_TYPE CONSTRAINT DM_PROFILE_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE ) FOREIGN KEY (DEVICE_TYPE, TENANT_ID)
REFERENCES DM_DEVICE_TYPE (NAME ) REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
@ -201,11 +201,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
FOREIGN KEY (POLICY_ID ) FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID ) REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE )
REFERENCES DM_DEVICE_TYPE (NAME )
ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );

Loading…
Cancel
Save