Merge branch 'qb1'
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
commit
8e47d8715b
36 files changed
+2053
-89
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { execDdl } from "../src/migration-helpers.ts";
|
||||
|
||||
// QB-1:下载任务直接记关联作品(接管任务按文件名识别 / 手动指定 / 手动整理后回填),作品详情"下载历史"据此列出
|
||||
// 没有计划与站点资源的接管任务。已有行按 计划 Slot → 站点资源 → 最近一次整理记录 回填。
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(
|
||||
db,
|
||||
`alter table download_task add column if not exists media_entity_id uuid references media_entity (id) on delete set null;
|
||||
create index if not exists download_task_media_entity_idx on download_task (media_entity_id) where media_entity_id is not null;
|
||||
update download_task dt set media_entity_id = coalesce(
|
||||
(select s.media_entity_id from acquisition_plan p join acquisition_slot s on s.id = p.slot_id where p.id = dt.acquisition_plan_id),
|
||||
(select sr.media_entity_id from source_release sr where sr.id = dt.source_release_id),
|
||||
(select r.media_entity_id from organization_record r
|
||||
where r.download_task_id = dt.id and r.media_entity_id is not null order by r.created_at desc limit 1))
|
||||
where dt.media_entity_id is null;`,
|
||||
);
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(
|
||||
db,
|
||||
`drop index if exists download_task_media_entity_idx;
|
||||
alter table download_task drop column if exists media_entity_id;`,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user