From 23827eb1cfaa6b9cdcff51ccc06d0deab62a34f0 Mon Sep 17 00:00:00 2001 From: a2a-cloud Date: Sat, 18 Jul 2026 04:47:30 +0000 Subject: [PATCH] a2a-source-edit: write db/migrations/004_quotejudge_current_contract.sql --- .../004_quotejudge_current_contract.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 db/migrations/004_quotejudge_current_contract.sql diff --git a/db/migrations/004_quotejudge_current_contract.sql b/db/migrations/004_quotejudge_current_contract.sql new file mode 100644 index 0000000..5a17994 --- /dev/null +++ b/db/migrations/004_quotejudge_current_contract.sql @@ -0,0 +1,24 @@ +-- Current QuoteJudge Studio contract. Additive only: supports fresh installs and +-- databases that previously applied older QuoteJudge migrations. +ALTER TABLE quote_comparisons + ADD COLUMN IF NOT EXISTS recommendation_vendor TEXT, + ADD COLUMN IF NOT EXISTS result JSONB; + +UPDATE quote_comparisons +SET recommendation_vendor = COALESCE(recommendation_vendor, recommended_vendor), + result = COALESCE(result, payload) +WHERE recommendation_vendor IS NULL OR result IS NULL; + +CREATE TABLE IF NOT EXISTS quote_judge_receipts ( + receipt_id TEXT PRIMARY KEY, + tenant_key TEXT NOT NULL, + comparison_id TEXT NOT NULL, + tool_name TEXT NOT NULL, + status TEXT NOT NULL, + input_hash TEXT NOT NULL, + payload JSONB NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS quote_judge_receipts_tenant_comparison_idx + ON quote_judge_receipts (tenant_key, comparison_id, created_at DESC);