fix(identity): persist verified auxiliary season mappings and reuse source ids

This commit is contained in:
root committed 2026-10-13 20:35:51 +08:00
1 parent c85b139ec4
commit ee0d62ae6f
15 files changed
+397 -38

No files matched your search

@@ -0,0 +1,24 @@
import type { Kysely } from "kysely";
import { execDdl } from "../src/migration-helpers.ts";
// Bangumi/豆瓣按分季建条目,一个 TMDB 作品可关联多个来源 ID;来源 ID 仍全局唯一。
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
export async function up(db: Kysely<any>): Promise<void> {
await execDdl(
db,
`drop index external_identity_entity_accepted_key;
create unique index external_identity_entity_accepted_key on external_identity (media_entity_id, provider, entity_type)
where status = 'accepted' and media_entity_id is not null and provider not in ('bangumi', 'douban');`,
);
}
// biome-ignore lint/suspicious/noExplicitAny: 同上
export async function down(db: Kysely<any>): Promise<void> {
// 已有多分季映射时唯一索引重建会拒绝回退,不删除或猜测保留哪条身份。
await execDdl(
db,
`drop index external_identity_entity_accepted_key;
create unique index external_identity_entity_accepted_key on external_identity (media_entity_id, provider, entity_type)
where status = 'accepted' and media_entity_id is not null;`,
);
}