新增发布校准数据库结构

This commit is contained in:
Codex
2026-06-24 11:04:38 +08:00
parent 7cd54738cc
commit f3d26e148a
2 changed files with 149 additions and 0 deletions
+75
View File
@@ -60,5 +60,80 @@ export function initializeSchema(db: Database.Database) {
foreign key (job_id, revision)
references optimized_articles(job_id, revision) on delete cascade
);
create table if not exists rubric_versions (
id text primary key,
version text not null,
name text not null,
dimensions text not null,
formula text not null,
is_active integer not null,
created_at text not null
);
create table if not exists scoring_runs (
id text primary key,
job_id text not null,
revision integer not null,
rubric_version_id text not null,
dimension_scores text not null,
composite_score real not null,
rationale text not null,
created_at text not null,
foreign key (job_id, revision)
references optimized_articles(job_id, revision) on delete cascade,
foreign key (rubric_version_id) references rubric_versions(id)
);
create table if not exists publication_records (
id text primary key,
job_id text not null,
revision integer not null,
platform text not null,
url text not null,
published_at text not null,
status text not null,
notes text not null,
created_at text not null,
updated_at text not null,
foreign key (job_id, revision)
references optimized_articles(job_id, revision) on delete cascade
);
create table if not exists performance_snapshots (
id text primary key,
publication_id text not null,
source text not null,
window_label text not null,
metrics text not null,
feedback_summary text not null,
raw_reference text,
snapshot_at text not null,
foreign key (publication_id) references publication_records(id) on delete cascade
);
create table if not exists calibration_events (
id text primary key,
publication_id text not null,
scoring_run_id text not null,
performance_snapshot_id text not null,
direction text not null,
observations text not null,
recommended_action text not null,
created_at text not null,
foreign key (publication_id) references publication_records(id) on delete cascade,
foreign key (scoring_run_id) references scoring_runs(id) on delete cascade,
foreign key (performance_snapshot_id)
references performance_snapshots(id) on delete cascade
);
create index if not exists idx_scoring_runs_job_revision
on scoring_runs(job_id, revision);
create index if not exists idx_publication_records_job_revision
on publication_records(job_id, revision);
create index if not exists idx_performance_snapshots_publication
on performance_snapshots(publication_id);
`);
}