mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix: ensure manually tagged faces have proper source type (#16364)
immich-app/immich#16062 added manual face tagging and deletion, but did not add a new 'SourceType'. The create faces would default to 'machine-learning' which is incorrect, and has the annoying downside that they will be wiped when the 'Refresh Faces' job is run. Handling of non-machine-learning faces was previously added in immich-app/immich#6455. This PR simply extends it to the new manually tagged faces.
This commit is contained in:
parent
8fbd650483
commit
4b55888d16
10 changed files with 63 additions and 6 deletions
27
server/src/migrations/1740619600996-AddManualSourceType.ts
Normal file
27
server/src/migrations/1740619600996-AddManualSourceType.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddManualSourceType1740619600996 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TYPE sourceType ADD VALUE 'manual'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
// Prior to this migration, manually tagged pictures had the 'machine-learning' type
|
||||
await queryRunner.query(
|
||||
`UPDATE "asset_faces" SET "sourceType" = 'machine-learning' WHERE "sourceType" = 'manual';`,
|
||||
);
|
||||
|
||||
// Postgres doesn't allow removing values from enums, we have to recreate the type
|
||||
await queryRunner.query(`ALTER TYPE sourceType RENAME TO oldSourceType`);
|
||||
await queryRunner.query(`CREATE TYPE sourceType AS ENUM ('machine-learning', 'exif');`);
|
||||
|
||||
await queryRunner.query(`ALTER TABLE "asset_faces" ALTER COLUMN "sourceType" DROP DEFAULT;`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "asset_faces" ALTER COLUMN "sourceType" TYPE sourceType USING "sourceType"::text::sourceType;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "asset_faces" ALTER COLUMN "sourceType" SET DEFAULT 'machine-learning'::sourceType;`,
|
||||
);
|
||||
await queryRunner.query(`DROP TYPE oldSourceType;`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue