Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Database): Change Foreign Key behaviour
Browse files Browse the repository at this point in the history
Add `ON DELETE CASCADE ON UPDATE CASCADE` For Foreign Key.
  • Loading branch information
Rhilip committed Feb 3, 2019
1 parent 1901e17 commit e263e07
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions migration/ridpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 02, 2019 at 08:38 AM
-- Generation Time: Feb 03, 2019 at 08:50 AM
-- Server version: 8.0.14
-- PHP Version: 7.3.1

Expand Down Expand Up @@ -652,37 +652,37 @@ ALTER TABLE `torrents` ADD FULLTEXT KEY `name` (`title`);
-- Constraints for table `files`
--
ALTER TABLE `files`
ADD CONSTRAINT `FK_files_torrents_id` FOREIGN KEY (`torrent_id`) REFERENCES `torrents` (`id`);
ADD CONSTRAINT `FK_files_torrents_id` FOREIGN KEY (`torrent_id`) REFERENCES `torrents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `invite`
--
ALTER TABLE `invite`
ADD CONSTRAINT `FK_invite_inviter_id` FOREIGN KEY (`inviter_id`) REFERENCES `users` (`id`);
ADD CONSTRAINT `FK_invite_inviter_id` FOREIGN KEY (`inviter_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `ip_bans`
--
ALTER TABLE `ip_bans`
ADD CONSTRAINT `FK_ip_ban_operator` FOREIGN KEY (`add_by`) REFERENCES `users` (`id`);
ADD CONSTRAINT `FK_ip_ban_operator` FOREIGN KEY (`add_by`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `snatched`
--
ALTER TABLE `snatched`
ADD CONSTRAINT `FK_snatched_torrentid` FOREIGN KEY (`torrent_id`) REFERENCES `torrents` (`id`),
ADD CONSTRAINT `FK_snatched_userid` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
ADD CONSTRAINT `FK_snatched_torrentid` FOREIGN KEY (`torrent_id`) REFERENCES `torrents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_snatched_userid` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `torrents`
--
ALTER TABLE `torrents`
ADD CONSTRAINT `FK_torrent_categories` FOREIGN KEY (`category`) REFERENCES `torrents_categories` (`id`),
ADD CONSTRAINT `FK_torrent_owner` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`);
ADD CONSTRAINT `FK_torrent_categories` FOREIGN KEY (`category`) REFERENCES `torrents_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_torrent_owner` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `users_session_log`
--
ALTER TABLE `users_session_log`
ADD CONSTRAINT `FK_session_user_id` FOREIGN KEY (`uid`) REFERENCES `users` (`id`);
ADD CONSTRAINT `FK_session_user_id` FOREIGN KEY (`uid`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

0 comments on commit e263e07

Please sign in to comment.