modified sql schema, create foreign key constraint while creating table.
CREATE TABLE IF NOT EXISTS `zstack`.`SNSSmsEndpointVO`
(
`uuid` varchar(32) NOT NULL UNIQUE,
- PRIMARY KEY (`uuid`)
+ PRIMARY KEY (`uuid`),
+ CONSTRAINT fkSNSSmsEndpointVOSNSApplicationEndpointVO FOREIGN KEY (uuid) REFERENCES SNSApplicationEndpointVO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
@@ -14,7 +15,8 @@ CREATE TABLE IF NOT EXISTS `zstack`.`SNSSmsReceiverVO`
`description` varchar(255) DEFAULT NULL,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
- PRIMARY KEY (`uuid`)
+ PRIMARY KEY (`uuid`),
+ CONSTRAINT fkSNSSmsReceiverVOSNSSmsEndpointVO FOREIGN KEY (endpointUuid) REFERENCES SNSSmsEndpointVO (uuid)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
@@ -25,26 +27,12 @@ CREATE TABLE IF NOT EXISTS `zstack`.`AliyunSmsSNSTextTemplateVO`
`alarmTemplateCode` varchar(24) NOT NULL,
`eventTemplateCode` varchar(24) NOT NULL,
`eventTemplate` text,
- PRIMARY KEY (`uuid`)
+ PRIMARY KEY (`uuid`),
+ CONSTRAINT fkAliyunSmsSNSTextTemplateVOSNSTextTemplateVO FOREIGN KEY (uuid) REFERENCES SNSTextTemplateVO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-# Foreign keys for table SNSSmsEndpointVO
-
-ALTER TABLE SNSSmsEndpointVO
- ADD CONSTRAINT fkSNSSmsEndpointVOSNSApplicationEndpointVO FOREIGN KEY (uuid) REFERENCES SNSApplicationEndpointVO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
-
-# Foreign keys for table SNSSmsReceiverVO
-
-ALTER TABLE SNSSmsReceiverVO
- ADD CONSTRAINT fkSNSSmsReceiverVOSNSSmsEndpointVO FOREIGN KEY (endpointUuid) REFERENCES SNSSmsEndpointVO (uuid);
-
-# Foreign keys for table AliyunSmsSNSTextTemplateVO
-
-ALTER TABLE AliyunSmsSNSTextTemplateVO
- ADD CONSTRAINT fkAliyunSmsSNSTextTemplateVOSNSTextTemplateVO FOREIGN KEY (uuid) REFERENCES SNSTextTemplateVO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
-
-# Remove the unique constrain of name in HybridAccountVO
+# Remove the unique constrain of name in HybridAccountVO, the second one is imported by someone on 3.4.0
ALTER TABLE HybridAccountVO
DROP INDEX name;
ALTER TABLE HybridAccountVO
