mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
Merge 46538a3052 into af33a78d18
This commit is contained in:
commit
a7d80c5d4a
4 changed files with 18 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue