diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 9591ed41f..ff7bd5d3f 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -331,7 +331,7 @@ DROP TABLE IF EXISTS `Frames`; CREATE TABLE `Frames` ( `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `EventId` BIGINT UNSIGNED NOT NULL default '0', - FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE, + /* FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE,*/ `FrameId` int(10) unsigned NOT NULL default '0', `Type` enum('Normal','Bulk','Alarm') NOT NULL default 'Normal', `TimeStamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -696,11 +696,11 @@ DROP TABLE IF EXISTS `Stats`; CREATE TABLE `Stats` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `MonitorId` int(10) unsigned NOT NULL default '0', - FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE, + /* FOREIGN KEY (`MonitorId`) REFERENCES `Monitors` (`Id`) ON DELETE CASCADE, */ `ZoneId` int(10) unsigned NOT NULL default '0', - FOREIGN KEY (`ZoneId`) REFERENCES `Zones` (`Id`) ON DELETE CASCADE, + /* FOREIGN KEY (`ZoneId`) REFERENCES `Zones` (`Id`) ON DELETE CASCADE, */ `EventId` BIGINT UNSIGNED NOT NULL, - FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE, + /* FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE, */ `FrameId` int(10) unsigned NOT NULL default '0', `PixelDiff` tinyint(3) unsigned NOT NULL default '0', `AlarmPixels` int(10) unsigned NOT NULL default '0', diff --git a/db/zm_update-1.37.31.sql b/db/zm_update-1.37.31.sql new file mode 100644 index 000000000..1157550c1 --- /dev/null +++ b/db/zm_update-1.37.31.sql @@ -0,0 +1,76 @@ +-- +-- Drop Foreign Keys on Events table. +-- + +SELECT 'Checking for FOREIGN KEYS on Events Table'; +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE + WHERE TABLE_NAME = 'Frames' + AND REFERENCED_TABLE_SCHEMA = DATABASE() + AND REFERENCED_TABLE_NAME = 'Events' + AND CONSTRAINT_NAME = 'Frames_ibfk_1' + ) > 0, +"ALTER TABLE Frames DROP FOREIGN KEY Frames_ibfk_1", +"SELECT 'FOREIGN KEY In Frames table already removed or has a different name.'" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE + WHERE TABLE_NAME = 'Stats' + AND REFERENCED_tABLE_SCHEMA = DATABASE() + AND REFERENCED_TABLE_NAME = 'Events' + AND CONSTRAINT_NAME = 'Stats_ibfk_1' + ) > 0, +"ALTER TABLE Stats DROP FOREIGN KEY Stats_ibfk_1", +"SELECT 'FOREIGN KEY In Stats table already removed or has a different name.'" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE + WHERE TABLE_NAME = 'Stats' + AND REFERENCED_tABLE_SCHEMA = DATABASE() + AND REFERENCED_TABLE_NAME = 'Events' + AND CONSTRAINT_NAME = 'Stats_ibfk_2' + ) > 0, +"ALTER TABLE Stats DROP FOREIGN KEY Stats_ibfk_2", +"SELECT 'FOREIGN KEY In Stats table already removed or has a different name.'" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE + WHERE TABLE_NAME = 'Stats' + AND REFERENCED_tABLE_SCHEMA = DATABASE() + AND REFERENCED_TABLE_NAME = 'Events' + AND CONSTRAINT_NAME = 'Stats_ibfk_3' + ) > 0, +"ALTER TABLE Stats DROP FOREIGN KEY Stats_ibfk_3", +"SELECT 'FOREIGN KEY In Stats table already removed or has a different name.'" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE + WHERE TABLE_NAME = 'Stats' + AND REFERENCED_tABLE_SCHEMA = DATABASE() + AND REFERENCED_TABLE_NAME = 'Events' + AND CONSTRAINT_NAME = 'Stats_ibfk_4' + ) > 0, +"ALTER TABLE Stats DROP FOREIGN KEY Stats_ibfk_4", +"SELECT 'FOREIGN KEY In Stats table already removed or has a different name.'" +)); diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index 711d6d9d9..b612f8c2c 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -24,7 +24,7 @@ %endif Name: zoneminder -Version: 1.37.30 +Version: 1.37.31 Release: 1%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons diff --git a/version b/version index 2cca8ea49..a05cda937 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.37.30 +1.37.31