Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
db: add theme_preference column to users table
  • Loading branch information
aslilac committed Dec 6, 2023
commit 765c638a150046fd317ee46708b566967b5b2a88
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE users ADD COLUMN "theme_preference" text;

COMMENT ON COLUMN "users"."theme_preference" IS 'null can be interpreted as "unset", defaulting to the operators default theme';
8 changes: 4 additions & 4 deletions coderd/database/migrations/create_migration.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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;
Expand Down