照 MP(chain/download/submission.py:明确指定 or 站点下载器 or 默认): - 迁移 0063:downloader_instance.is_default(至多一个,唯一索引)、site.downloader_instance_id - pickInstance:明确指定 > 站点指定 > 默认 > 第一个可用;自动下载(gates)与手动下载共用 - 设置:下载器名称改称别名,新增「设为默认下载器」;站点编辑新增「下载器」选择 - 测试 downloader-routing.test.ts Co-Authored-By: Claude Opus 5.5 <[email protected]>
24 lines
1.2 KiB
TypeScript
24 lines
1.2 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { execDdl } from "../src/migration-helpers.ts";
|
|
|
|
// 多下载器路由(照 MP):下载器选择 = 明确指定(订阅 / 手动)> 站点指定 > 默认下载器 > 第一个可用。
|
|
// 默认下载器至多一个;站点指定的下载器被删时回落默认。
|
|
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`alter table downloader_instance add column if not exists is_default boolean not null default false;
|
|
create unique index if not exists downloader_instance_one_default on downloader_instance ((true)) where is_default;
|
|
alter table site add column if not exists downloader_instance_id uuid references downloader_instance (id) on delete set null;`,
|
|
);
|
|
}
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`alter table site drop column if exists downloader_instance_id;
|
|
drop index if exists downloader_instance_one_default;
|
|
alter table downloader_instance drop column if exists is_default;`,
|
|
);
|
|
}
|