This commit is contained in:
Devesh Kolte 2026-08-14 00:28:41 +01:00 committed by GitHub
commit a7d80c5d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 5 deletions

View file

@ -246,7 +246,7 @@ export type Person = {
updatedAt: Date;
updateId: string;
isFavorite: boolean;
name: string;
name: string | null;
birthDate: Date | null;
color: string | null;
faceAssetId: string | null;

View file

@ -14,7 +14,7 @@ import z from 'zod';
const PersonCreateSchema = z
.object({
name: z.string().optional().describe('Person name'),
name: z.string().nullish().transform((val) => (val === '' ? null : val)).describe('Person name'),
birthDate: z
.string()
.meta({ format: 'date' })
@ -61,7 +61,7 @@ const PersonSearchSchema = z
export const PersonResponseSchema = z
.object({
id: z.uuidv4().describe('Person ID'),
name: z.string().describe('Person name'),
name: z.string().nullable().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'),

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 "name" DROP NOT NULL;`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "name" SET DEFAULT NULL;`.execute(db);
await sql`UPDATE "person" SET "name" = NULL WHERE "name" = '';`.execute(db);
}
export async function down(): Promise<void> {
await sql`UPDATE "person" SET "name" = '' WHERE "name" IS NULL;`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "name" SET DEFAULT '';`.execute(db);
await sql`ALTER TABLE "person" ALTER COLUMN "name" SET NOT NULL;`.execute(db);
}

View file

@ -43,8 +43,8 @@ export class PersonTable {
@ForeignKeyColumn(() => UserTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
ownerId!: string;
@Column({ default: '' })
name!: Generated<string>;
@Column({ nullable: true, default: null })
name!: string | null;
@Column({ default: '' })
thumbnailPath!: Generated<string>;