-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update migration to make color an integer.
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 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,8 @@ | ||
ALTER TABLE custom_roles DROP COLUMN user_id; | ||
|
||
BEGIN; | ||
ALTER TABLE custom_roles ADD COLUMN old_color VARCHAR NOT NULL; | ||
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; | ||
COMMIT; |
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,11 @@ | ||
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; | ||
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; | ||
COMMIT; |