33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { execDdl } from "../src/migration-helpers.ts";
|
|
|
|
// 补字幕(docs/plan/subtitles.md):每次写入一个字幕文件记一行,撤销时删文件、有备份就还原。
|
|
// 写入的字幕同时登记为 media_asset(kind = subtitle)+ asset_location(sidecar_of_location_id 指向视频位置)。
|
|
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`create table if not exists subtitle_write (
|
|
id uuid primary key default gen_random_uuid(),
|
|
media_entity_id uuid not null references media_entity (id) on delete cascade,
|
|
video_location_id uuid references asset_location (id) on delete set null,
|
|
subtitle_asset_id uuid references media_asset (id) on delete set null,
|
|
library_root_id uuid not null references library_root (id) on delete cascade,
|
|
relative_path text not null,
|
|
language text not null,
|
|
source text not null check (source in ('upload', 'subhd', 'zimuku')),
|
|
source_name text not null,
|
|
source_ref text,
|
|
backup_path text,
|
|
actor text,
|
|
created_at timestamptz not null default now(),
|
|
undone_at timestamptz
|
|
);
|
|
create index if not exists subtitle_write_entity on subtitle_write (media_entity_id, created_at desc);`,
|
|
);
|
|
}
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(db, "drop table if exists subtitle_write;");
|
|
}
|