-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: Allow DELETE FROM Devices, cascade Media and EventsCam
This is to get out of the tricky situation when removing a camera may fail if a new Media or EventsCam record appeared during the removal. Removal entails deleting recordings from the filesystem, which can take substantial time, and we have actually got report of this problem.
- Loading branch information
1 parent
6a84d1e
commit 46c04e5
Showing
3 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3000012 | ||
3010400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
echo ' | ||
ALTER TABLE EventsCam DROP CONSTRAINT `EventsCam_ibfk_3`; | ||
ALTER TABLE EventsCam ADD CONSTRAINT `EventsCam_ibfk_3` FOREIGN KEY (`device_id`) REFERENCES `Devices` (`id`) ON UPDATE CASCADE ON DELETE CASCADE; | ||
ALTER TABLE Media DROP CONSTRAINT `Media_ibfk_1`; | ||
ALTER TABLE Media ADD CONSTRAINT `Media_ibfk_1` FOREIGN KEY (`device_id`) REFERENCES `Devices` (`id`) ON UPDATE CASCADE ON DELETE CASCADE; | ||
' | mysql -h"$host" -D"$dbname" -u"$user" -p"$password" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters