feat(db): create locale column in user table

This commit is contained in:
Nicolas Meienberger 2023-05-06 13:20:16 +02:00
parent acdeb0f416
commit 2cdad4b1ec
2 changed files with 16 additions and 0 deletions

View file

@ -24,6 +24,7 @@ export const userTable = pgTable('user', {
totpSecret: text('totp_secret'),
totpEnabled: boolean('totp_enabled').default(false).notNull(),
salt: text('salt'),
locale: varchar('locale').default('en').notNull(),
});
export type User = InferModel<typeof userTable>;
export type NewUser = InferModel<typeof userTable, 'insert'>;

View file

@ -0,0 +1,15 @@
-- Create locale field if it doesn't exist
ALTER TABLE "user"
ADD COLUMN IF NOT EXISTS "locale" character varying DEFAULT 'en';
-- Set default locale to en
UPDATE
"user"
SET
"locale" = 'en'
WHERE
"locale" IS NULL;
-- Set locale column to not null constraint
ALTER TABLE "user"
ALTER COLUMN "locale" SET NOT NULL;