Restructure guilds table

This commit is contained in:
jude
2025-05-23 22:04:21 +01:00
parent 19cfacffe5
commit 192e316926
20 changed files with 86 additions and 97 deletions

View File

@ -5,8 +5,11 @@ DROP TABLE IF EXISTS embeds;
DROP TABLE IF EXISTS embed_fields;
DROP TABLE IF EXISTS command_aliases;
DROP TABLE IF EXISTS macro;
DROP TABLE IF EXISTS command_restrictions;
DROP TABLE IF EXISTS roles;
SET FOREIGN_KEY_CHECKS = 0;
-- Drop columns from channels that are no longer used
ALTER TABLE channels DROP COLUMN `name`;
ALTER TABLE channels DROP COLUMN `blacklisted`;
@ -54,7 +57,6 @@ CREATE TABLE `todos_new` (
INSERT INTO todos_new (id, guild_id, channel_id, user_id, value) SELECT id, (SELECT guild FROM guilds_old WHERE id = guild_id), channel_id, user_id, value FROM todos;
RENAME TABLE todos TO todos_old;
RENAME TABLE todos_new TO todos;
DROP TABLE todos_old;
-- Update fk on reminder_template to point at new guild table
ALTER TABLE reminder_template
@ -76,4 +78,7 @@ ALTER TABLE command_macro
ON UPDATE CASCADE;
UPDATE command_macro SET guild_id = (SELECT guild FROM guilds_old WHERE id = guild_id);
DROP TABLE todos_old;
DROP TABLE guilds_old;
SET FOREIGN_KEY_CHECKS = 1;