fix(server): store null instead of empty string for person thumbnailPath

This commit is contained in:
Devesh Kolte 2026-07-20 19:04:42 +05:30
parent d7f46ccee3
commit 71a9070f4a
4 changed files with 17 additions and 4 deletions

View file

@ -251,7 +251,7 @@ export type Person = {
color: string | null;
faceAssetId: string | null;
isHidden: boolean;
thumbnailPath: string;
thumbnailPath: string | null;
};
export type AssetFace = {

View file

@ -64,7 +64,7 @@ export const PersonResponseSchema = z
name: z.string().describe('Person name'),
// TODO: use `isoDateToDate` when using `ZodSerializerDto` on the controllers.
birthDate: z.string().meta({ format: 'date' }).describe('Person date of birth').nullable(),
thumbnailPath: z.string().describe('Thumbnail path'),
thumbnailPath: z.string().nullable().describe('Thumbnail path'),
isHidden: z.boolean().describe('Is hidden'),
// TODO: use `isoDatetimeToDate` when using `ZodSerializerDto` on the controllers.
updatedAt: z

View file

@ -0,0 +1,13 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`ALTER TABLE "person" ALTER COLUMN "thumbnailPath" DROP NOT NULL;`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "thumbnailPath" SET DEFAULT NULL;`.execute(db);
await sql`UPDATE "person" SET "thumbnailPath" = NULL WHERE "thumbnailPath" = '';`.execute(db);
}
export async function down(): Promise<void> {
await sql`UPDATE "person" SET "thumbnailPath" = '' WHERE "thumbnailPath" IS NULL;`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "thumbnailPath" SET DEFAULT '';`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "thumbnailPath" SET NOT NULL;`.execute(db);
}

View file

@ -46,8 +46,8 @@ export class PersonTable {
@Column({ default: '' })
name!: Generated<string>;
@Column({ default: '' })
thumbnailPath!: Generated<string>;
@Column({ nullable: true, default: null })
thumbnailPath!: string | null;
@Column({ type: 'boolean', default: false })
isHidden!: Generated<boolean>;