feat(db): 待处理新增「下载器连不上」「下载目录读不到容量」两类(迁移 0073)
decision.kind 增加 downloader_offline / cache_volume_unknown,契约、原因文案与界面标签同步; volume_state_unknown 的原因文案改为「下载目录读不到容量」并指向路径映射与容器挂载。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
0085e45ca7
commit
74f2c7649e
6 files changed
+54
-2
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { execDdl, oneOf } from "../src/migration-helpers.ts";
|
||||
|
||||
// 下载侧可见性:decision.kind 增加
|
||||
// - downloader_offline:下载器连续不可达超过一段时间(按实例去重,恢复后自动关闭)
|
||||
// - cache_volume_unknown:下载目录读不到容量(路径映射 / 挂载问题,按卷去重,恢复后自动关闭)
|
||||
|
||||
const OLD_DECISION_KINDS = [
|
||||
"identity_ambiguous",
|
||||
"download_stalled",
|
||||
"download_failed",
|
||||
"path_conflict",
|
||||
"space_insufficient",
|
||||
"approval_required",
|
||||
"metadata_conflict",
|
||||
"source_unreachable",
|
||||
"other",
|
||||
"identity_unresolved",
|
||||
"episode_mapping",
|
||||
];
|
||||
const NEW_DECISION_KINDS = [...OLD_DECISION_KINDS, "downloader_offline", "cache_volume_unknown"];
|
||||
|
||||
const swapDecisionKinds = (values: readonly string[]) => `
|
||||
alter table decision drop constraint decision_kind_check;
|
||||
alter table decision add constraint decision_kind_check ${oneOf("kind", values)};
|
||||
`;
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(db, swapDecisionKinds(NEW_DECISION_KINDS));
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(
|
||||
db,
|
||||
`update decision set kind = 'other' where kind in ('downloader_offline', 'cache_volume_unknown');
|
||||
${swapDecisionKinds(OLD_DECISION_KINDS)}`,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user