missing_since / missing_count 记录 qB 里连续查不到的起点与轮数;generation 记录 removed 行复活次数,用于完成事件幂等键换代。contracts DownloadTask 同步为可选字段。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { execDdl } from "../src/migration-helpers.ts";
|
|
|
|
// 下载调度卡死修复(docs/plan/system-review.md ③):
|
|
// - missing_since / missing_count:qB 列表与按 hash 查都查不到时先记缺席,连续多轮才判 removed,中途出现即清零
|
|
// - generation:同一 (实例, hash) 的 removed 行被再次提交 / 接管而复活时 +1,完成事件幂等键随之换代,
|
|
// 复活后的完成仍能触发整理
|
|
// 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 missing_since timestamptz;
|
|
alter table download_task add column if not exists missing_count integer not null default 0;
|
|
alter table download_task add column if not exists generation integer not null default 0;`,
|
|
);
|
|
}
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`alter table download_task drop column if exists missing_since;
|
|
alter table download_task drop column if exists missing_count;
|
|
alter table download_task drop column if exists generation;`,
|
|
);
|
|
}
|