- Sites / accounts / feeds: registry view (/site-definitions), site CRUD with
enable/disable (history stays queryable, marked site_disabled), accounts and
feed URLs stored as secrets (only secret_ref / redacted urlDisplay exposed),
feed enable/disable/reset/fetch; one shared rate limiter + adapter per site.
- Tasks: ingestFeed (FeedFetchState/FeedCursor on feed_source, observation
feed+guid upsert with digest-change updates, source_release site+id
aggregation across feeds, auth failure -> account invalid + decision, no
retry, gap -> feed.gap_suspected -> budgeted backfill snapshot),
resolveObservation (parseRelease -> local recall via title_alias pg_trgm +
accepted identities -> TMDB -> resolveIdentity; auto binds entity /
provisional units / identities / aliases, otherwise identity_candidate pool
with evidence version and bounded review backoff; manual lock respected),
refreshMetadata (metadata_field + field_override, user locks win, paths
untouched), snapshotSite (site_snapshot coverage records).
- Events: feed.due, feed.gap_suspected, release.observed (self-consumed),
release.resolved, decision.created/updated; scheduler in worker start().
- Identity API: entity detail with redirects, manual mapping correction with
identity_revision, merge with identity_redirect, pool list/assign/dismiss/
retry, content unit numbering lock, aliases, external identities.
- Decisions: list/summary (by entity and kind)/detail/resolve; identity
options executed directly.
- Workbench: /sites/{id}/releases (snapshot first, coalesced live search with
backoff, origin + freshness) and /sites/{id}/releases/{rid} (volatile field
recheck times, refresh keeps data on failure).
- Capabilities: catalog.lookup, release.search, release.inspect,
identity.resolve.
- Migrations 0018-0020: site.adapter api, source_release.resolution_locked,
site_snapshot, identity_candidate, resolution_attempt, identity_redirect,
metadata_field, field_override.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { dropTables, entityTable, execDdl, oneOf } from "../src/migration-helpers.ts";
|
|
|
|
// W2-B 来源补充(REQ §4.5、§4.6、§7.5):
|
|
// - site.adapter 增加 api(MP 专用 API spider:Haidan/HDDolby/RousiPro/…,见 adapters/sites/spiders);
|
|
// - source_release.resolution_locked:人工确认的身份关联,自动识别不得改写;
|
|
// - site_snapshot:每次列表快照/实时补查/补漏的覆盖范围与新鲜度(不把一次分页伪称全站快照)。
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`
|
|
alter table site drop constraint site_adapter_check;
|
|
alter table site add constraint site_adapter_check ${oneOf("adapter", ["nexusphp", "mteam_api", "api", "generic_rss"])};
|
|
|
|
alter table source_release add column resolution_locked boolean not null default false;
|
|
|
|
${entityTable(
|
|
"site_snapshot",
|
|
`
|
|
site_id uuid not null references site (id) on delete cascade,
|
|
kind text not null ${oneOf("kind", ["periodic", "backfill", "live_search", "manual"])},
|
|
query text,
|
|
filters jsonb not null default '{}'::jsonb,
|
|
pages jsonb not null default '[]'::jsonb,
|
|
item_count integer not null default 0,
|
|
new_count integer not null default 0,
|
|
status text not null default 'running' ${oneOf("status", ["running", "ok", "partial", "failed"])},
|
|
error jsonb,
|
|
definition_version text,
|
|
started_at timestamptz not null default now(),
|
|
finished_at timestamptz`,
|
|
)}
|
|
create index site_snapshot_site_idx on site_snapshot (site_id, started_at desc);
|
|
`,
|
|
);
|
|
}
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`
|
|
${dropTables(["site_snapshot"])}
|
|
alter table source_release drop column if exists resolution_locked;
|
|
alter table site drop constraint site_adapter_check;
|
|
alter table site add constraint site_adapter_check ${oneOf("adapter", ["nexusphp", "mteam_api", "generic_rss"])};
|
|
`,
|
|
);
|
|
}
|