fix(server): store null instead of empty string for user password (#30223)

This commit is contained in:
Devesh Kolte
2026-07-30 15:19:58 -04:00
committed by GitHub
parent 56fbca910e
commit 9732bebb55
2 changed files with 15 additions and 2 deletions
@@ -0,0 +1,13 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`ALTER TABLE "user" ALTER COLUMN "password" DROP NOT NULL;`.execute(db);
await sql`ALTER TABLE "user" ALTER COLUMN "password" SET DEFAULT NULL;`.execute(db);
await sql`UPDATE "user" SET "password" = NULL WHERE "password" = '';`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`UPDATE "user" SET "password" = '' WHERE "password" IS NULL;`.execute(db);
await sql`ALTER TABLE "user" ALTER COLUMN "password" SET DEFAULT '';`.execute(db);
await sql`ALTER TABLE "user" ALTER COLUMN "password" SET NOT NULL;`.execute(db);
}
+2 -2
View File
@@ -31,8 +31,8 @@ export class UserTable {
@Column({ unique: true })
email!: string;
@Column({ default: '' })
password!: Generated<string>;
@Column({ nullable: true, default: null })
password!: string | null;
@Column({ nullable: true })
pinCode!: string | null;