From d7afd08eaf46da8afb7670647dabf190ca7e254b Mon Sep 17 00:00:00 2001 From: oabrivard Date: Tue, 24 Mar 2026 18:51:10 +0100 Subject: [PATCH] feat: enrich article_history with tracing metadata + syntheses.job_id --- CLAUDE.md | 2 +- .../20260324000016_enrich_article_history.sql | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 backend/migrations/20260324000016_enrich_article_history.sql diff --git a/CLAUDE.md b/CLAUDE.md index 954ef11..c43d135 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -117,7 +117,7 @@ cd frontend && npx tsc --noEmit - `GET /api/v1/admin/users` — user list - `PUT /api/v1/admin/users/:id/role` — role management -## Database (15 migrations) +## Database (16 migrations) Tables: `users`, `sessions`, `magic_link_tokens`, `user_settings`, `sources`, `syntheses`, `admin_providers`, `admin_rate_limits`, `user_api_keys`, `audit_log` ## Environment Variables diff --git a/backend/migrations/20260324000016_enrich_article_history.sql b/backend/migrations/20260324000016_enrich_article_history.sql new file mode 100644 index 0000000..205e9ca --- /dev/null +++ b/backend/migrations/20260324000016_enrich_article_history.sql @@ -0,0 +1,17 @@ +-- Enrich article_history with tracing metadata +ALTER TABLE article_history ADD COLUMN title TEXT NOT NULL DEFAULT ''; +ALTER TABLE article_history ADD COLUMN source_type TEXT NOT NULL DEFAULT 'unknown'; +ALTER TABLE article_history ADD COLUMN source_url TEXT; +ALTER TABLE article_history ADD COLUMN category TEXT; +ALTER TABLE article_history ADD COLUMN synthesis_id UUID REFERENCES syntheses(id) ON DELETE SET NULL; +ALTER TABLE article_history ADD COLUMN status TEXT NOT NULL DEFAULT 'used'; +ALTER TABLE article_history ADD COLUMN scraped_ok BOOLEAN NOT NULL DEFAULT true; +ALTER TABLE article_history ADD COLUMN job_id UUID NOT NULL DEFAULT gen_random_uuid(); + +-- Drop unique index — table is now a trace log +DROP INDEX idx_article_history_user_url; +CREATE INDEX idx_article_history_user_url ON article_history(user_id, url_hash); +CREATE INDEX idx_article_history_job_id ON article_history(job_id); + +-- Store job_id on syntheses for direct provenance lookup +ALTER TABLE syntheses ADD COLUMN job_id UUID;