From 12902a19ba672255934e84b8698e07f476184c6b Mon Sep 17 00:00:00 2001 From: a2a-cloud Date: Sat, 18 Jul 2026 10:14:20 +0000 Subject: [PATCH] a2a-source-edit: write db/migrations/001_invoice_guard.sql --- db/migrations/001_invoice_guard.sql | 40 +++-------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/db/migrations/001_invoice_guard.sql b/db/migrations/001_invoice_guard.sql index 1b18757..db8ef92 100644 --- a/db/migrations/001_invoice_guard.sql +++ b/db/migrations/001_invoice_guard.sql @@ -1,37 +1,3 @@ -CREATE TABLE IF NOT EXISTS invoice_cases ( - id BIGSERIAL PRIMARY KEY, - tenant_key TEXT NOT NULL, - case_id TEXT NOT NULL, - invoice_count INTEGER NOT NULL DEFAULT 0, - duplicate_count INTEGER NOT NULL DEFAULT 0, - total_mismatch_count INTEGER NOT NULL DEFAULT 0, - invoices JSONB NOT NULL DEFAULT '[]'::jsonb, - duplicates JSONB NOT NULL DEFAULT '[]'::jsonb, - total_mismatches JSONB NOT NULL DEFAULT '[]'::jsonb, - decisions JSONB NOT NULL DEFAULT '[]'::jsonb, - receipt JSONB NOT NULL DEFAULT '{}'::jsonb, - created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - UNIQUE (tenant_key, case_id) -); - -CREATE INDEX IF NOT EXISTS invoice_cases_tenant_updated_idx - ON invoice_cases (tenant_key, updated_at DESC); - -CREATE INDEX IF NOT EXISTS invoice_cases_tenant_counts_idx - ON invoice_cases (tenant_key, duplicate_count, total_mismatch_count); - -CREATE TABLE IF NOT EXISTS invoice_execution_receipts ( - id BIGSERIAL PRIMARY KEY, - tenant_key TEXT NOT NULL, - receipt_id TEXT NOT NULL, - case_id TEXT NOT NULL, - skill TEXT NOT NULL, - input_hash TEXT NOT NULL, - receipt JSONB NOT NULL, - created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - UNIQUE (tenant_key, receipt_id) -); - -CREATE INDEX IF NOT EXISTS invoice_receipts_case_idx - ON invoice_execution_receipts (tenant_key, case_id, created_at DESC); +-- InvoiceGuard schema lives in 001_app_records.sql. This no-op file is kept +-- only because the scaffolded workspace may already include it during builder +-- retries; migrations are idempotent and safe for fresh installs.