From 048b9c88b77b92a158c3c53df2d176a796ee4931 Mon Sep 17 00:00:00 2001 From: a2a-cloud Date: Sat, 18 Jul 2026 05:35:30 +0000 Subject: [PATCH] a2a-source-edit: write db/migrations/005_quotejudge_receipt_compat.sql --- .../005_quotejudge_receipt_compat.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 db/migrations/005_quotejudge_receipt_compat.sql diff --git a/db/migrations/005_quotejudge_receipt_compat.sql b/db/migrations/005_quotejudge_receipt_compat.sql new file mode 100644 index 0000000..05ebabf --- /dev/null +++ b/db/migrations/005_quotejudge_receipt_compat.sql @@ -0,0 +1,34 @@ +-- Receipt compatibility for all historical QuoteJudge schemas. Additive only. +CREATE TABLE IF NOT EXISTS quote_judge_receipts ( + id BIGSERIAL PRIMARY KEY, + receipt_id TEXT, + tenant_key TEXT NOT NULL, + comparison_id TEXT, + skill_name TEXT, + tool_name TEXT, + status TEXT, + input_hash TEXT, + result_hash TEXT, + receipt_json JSONB, + payload JSONB, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS receipt_id TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS skill_name TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS tool_name TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS status TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS input_hash TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS result_hash TEXT; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS receipt_json JSONB; +ALTER TABLE quote_judge_receipts ADD COLUMN IF NOT EXISTS payload JSONB; + +UPDATE quote_judge_receipts +SET tool_name = COALESCE(tool_name, skill_name), + skill_name = COALESCE(skill_name, tool_name), + payload = COALESCE(payload, receipt_json), + receipt_json = COALESCE(receipt_json, payload) +WHERE tool_name IS NULL OR skill_name IS NULL OR payload IS NULL OR receipt_json IS NULL; + +CREATE INDEX IF NOT EXISTS quote_judge_receipts_tenant_idx + ON quote_judge_receipts (tenant_key, created_at DESC);