chore: add theme_preference column to users table (#11069)

This commit is contained in:
Kayla Washburn
2023-12-08 14:59:53 -07:00
committed by GitHub
parent ebd6c1b573
commit d8e95001e8
10 changed files with 55 additions and 30 deletions

View File

@ -0,0 +1 @@
ALTER TABLE users DROP COLUMN "theme_preference";

View File

@ -0,0 +1,3 @@
ALTER TABLE users ADD COLUMN "theme_preference" text NOT NULL DEFAULT '';
COMMENT ON COLUMN "users"."theme_preference" IS '"" can be interpreted as "the user does not care", falling back to the default theme';

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
# Usage:
# ./create_migration name of migration
# ./create_migration "name of migration"
# ./create_migration name_of_migration
# ./create_migration.sh name of migration
# ./create_migration.sh "name of migration"
# ./create_migration.sh name_of_migration
set -euo pipefail
@ -27,7 +27,7 @@ CREATE TYPE new_logintype AS ENUM (
ALTER TABLE users
ALTER COLUMN login_type DROP DEFAULT, -- if the column has a default, it must be dropped first
ALTER COLUMN login_type TYPE new_logintype USING (login_type::text::new_logintype), -- converts the old enum until the new enum using text as an intermediary
ALTER COLUMN login_type TYPE new_logintype USING (login_type::text::new_logintype), -- converts the old enum into the new enum using text as an intermediary
ALTER COLUMN login_type SET DEFAULT 'password'::new_logintype; -- re-add the default using the new enum
DROP TYPE login_type;