From f1a8d5f1ff2f775bf915d3f6c48c23e8112e6a05 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 5 Apr 2018 13:41:24 -0700 Subject: [PATCH] start of work on .41. Adding foreign keysy --- db/zm_update-1.31.41.sql | 30 ++++++++++++++++++++++++++++++ web/api/app/Plugin/Crud | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 db/zm_update-1.31.41.sql diff --git a/db/zm_update-1.31.41.sql b/db/zm_update-1.31.41.sql new file mode 100644 index 000000000..41ef7a3fa --- /dev/null +++ b/db/zm_update-1.31.41.sql @@ -0,0 +1,30 @@ + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Storage' + AND column_name = 'DoDelete' + ) > 0, +"SELECT 'Column DoDelete already exists in Storage'", +"ALTER TABLE `Storage` ADD `DoDelete` BOOLEAN NOT NULL default true AFTER `ServerId`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Events' + AND column_name = 'Locked' + ) > 0, +"SELECT 'Column Locked already exists in Events'", +"ALTER TABLE `Events` ADD `Locked` BOOLEAN NOT NULL default false AFTER `Scheme`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; +ALTER TABLE `Stats` ADD FOREIGN KEY (`MonitorId`) REFERENCES `Monitors`(`Id`) ON DELETE CASCADE; +ALTER TABLE `Stats` ADD FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE; +ALTER TABLE `Stats` ADD FOREIGN KEY (`ZoneId`) REFERENCES `Zones`(`Id`) ON DELETE CASCADE; + +ALTER TABLE `Frames` ADD FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE; +ALTER TABLE `Frames` DROP INDEX `Type`; diff --git a/web/api/app/Plugin/Crud b/web/api/app/Plugin/Crud index 1351dde6b..c3976f147 160000 --- a/web/api/app/Plugin/Crud +++ b/web/api/app/Plugin/Crud @@ -1 +1 @@ -Subproject commit 1351dde6b4c75b215099ae8bcf5a21d6c6e10298 +Subproject commit c3976f1478c681b0bbc132ec3a3e82c3984eeed5