Skip to content

Commit

Permalink
Merge pull request #260 from SylteA/dev
Browse files Browse the repository at this point in the history
Update migration
  • Loading branch information
SylteA authored Nov 13, 2023
2 parents de052ed + 1c5f1e4 commit 12c14c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bot/models/migrations/005_down__custom_role.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ALTER TABLE custom_roles DROP COLUMN user_id;

BEGIN;
ALTER TABLE custom_roles ADD COLUMN old_color VARCHAR NOT NULL;
ALTER TABLE custom_roles ADD COLUMN old_color VARCHAR;
UPDATE custom_roles SET old_color = CAST(color AS VARCHAR);
ALTER TABLE custom_roles DROP COLUMN color;
ALTER TABLE custom_roles RENAME COLUMN old_color TO color;
ALTER TABLE custom_ROLES ALTER COLUMN color SET NOT NULL;
COMMIT;
3 changes: 2 additions & 1 deletion bot/models/migrations/005_up__custom_roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ ALTER TABLE custom_roles ADD COLUMN user_id BIGINT;
-- Create a temporary column `new_color` and update the table with the values from this table.
-- Drop the old color column, then rename the new one and set it to non-nullable.
BEGIN;
ALTER TABLE custom_roles ADD COLUMN new_color INTEGER NOT NULL;
ALTER TABLE custom_roles ADD COLUMN new_color INTEGER;
UPDATE custom_roles SET new_color = CAST(color AS INTEGER);
ALTER TABLE custom_roles DROP COLUMN color;
ALTER TABLE custom_roles RENAME COLUMN new_color TO color;
ALTER TABLE custom_roles ALTER COLUMN color SET NOT NULL;
COMMIT;

0 comments on commit 12c14c2

Please sign in to comment.