diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 7b6a9f49..488b38e8 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -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; export type NewUser = InferModel; diff --git a/src/server/migrations/00007-add-locale-user-col.sql b/src/server/migrations/00007-add-locale-user-col.sql new file mode 100644 index 00000000..65f5ef53 --- /dev/null +++ b/src/server/migrations/00007-add-locale-user-col.sql @@ -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;