2023-08-12 11:27:15 +00:00
|
|
|
-- Drop existing constraint
|
2023-08-19 20:21:56 +00:00
|
|
|
ALTER TABLE `reminders` DROP CONSTRAINT `reminders_ibfk_1`;
|
2023-08-12 11:27:15 +00:00
|
|
|
|
2023-08-19 20:21:56 +00:00
|
|
|
ALTER TABLE `reminders` MODIFY COLUMN `channel_id` INT UNSIGNED;
|
|
|
|
ALTER TABLE `reminders` ADD COLUMN `guild_id` INT UNSIGNED;
|
2023-08-12 11:27:15 +00:00
|
|
|
|
|
|
|
ALTER TABLE `reminders`
|
|
|
|
ADD CONSTRAINT `guild_id_fk`
|
|
|
|
FOREIGN KEY (`guild_id`)
|
|
|
|
REFERENCES `guilds`(`id`)
|
|
|
|
ON DELETE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE `reminders`
|
|
|
|
ADD CONSTRAINT `channel_id_fk`
|
|
|
|
FOREIGN KEY (`channel_id`)
|
|
|
|
REFERENCES `channels`(`id`)
|
|
|
|
ON DELETE SET NULL;
|
|
|
|
|
2023-08-19 20:21:56 +00:00
|
|
|
UPDATE `reminders` SET `guild_id` = (SELECT guilds.`id` FROM `channels` INNER JOIN `guilds` ON channels.guild_id = guilds.id WHERE reminders.channel_id = channels.id);
|