a2a-source-edit: write db/migrations/001_app_records.sql

This commit is contained in:
a2a-cloud
2026-07-19 19:57:18 +00:00
parent 5f99e3f722
commit 5c5620236e

View File

@@ -1,11 +1,34 @@
CREATE TABLE IF NOT EXISTS app_records ( CREATE TABLE IF NOT EXISTS sales_dashboards (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
tenant_key TEXT NOT NULL, tenant_key TEXT NOT NULL,
record_kind TEXT NOT NULL, dashboard_id TEXT NOT NULL,
dashboard_name TEXT NOT NULL,
segment TEXT NOT NULL,
period_label TEXT NOT NULL,
pipeline_total_usd NUMERIC(14, 2) NOT NULL DEFAULT 0,
exception_count INTEGER NOT NULL DEFAULT 0,
payload JSONB NOT NULL, payload JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() UNIQUE (tenant_key, dashboard_id)
); );
CREATE INDEX IF NOT EXISTS app_records_tenant_kind_idx CREATE INDEX IF NOT EXISTS sales_dashboards_tenant_created_idx
ON app_records (tenant_key, record_kind, created_at DESC); ON sales_dashboards (tenant_key, created_at DESC);
CREATE INDEX IF NOT EXISTS sales_dashboards_tenant_segment_idx
ON sales_dashboards (tenant_key, segment, created_at DESC);
CREATE TABLE IF NOT EXISTS execution_receipts (
id BIGSERIAL PRIMARY KEY,
tenant_key TEXT NOT NULL,
receipt_id TEXT NOT NULL,
dashboard_id TEXT NOT NULL,
skill_name TEXT NOT NULL,
status TEXT NOT NULL,
payload JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (tenant_key, receipt_id)
);
CREATE INDEX IF NOT EXISTS execution_receipts_tenant_dashboard_idx
ON execution_receipts (tenant_key, dashboard_id, created_at DESC);