import type { Kysely } from "kysely"; import { execDdl } from "../src/migration-helpers.ts"; // 多下载器路由(照 MP):下载器选择 = 明确指定(订阅 / 手动)> 站点指定 > 默认下载器 > 第一个可用。 // 默认下载器至多一个;站点指定的下载器被删时回落默认。 // biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型 export async function up(db: Kysely): Promise { 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): Promise { 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;`, ); }