feat(db): create locale column in user table
This commit is contained in:
parent
acdeb0f416
commit
2cdad4b1ec
2 changed files with 16 additions and 0 deletions
|
@ -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'>;
|
||||
|
|
15
src/server/migrations/00007-add-locale-user-col.sql
Normal file
15
src/server/migrations/00007-add-locale-user-col.sql
Normal 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;
|
Loading…
Add table
Reference in a new issue