a2a-source-edit: write db/migrations/001_app_records.sql
This commit is contained in:
@@ -1,11 +1,34 @@
|
||||
CREATE TABLE IF NOT EXISTS app_records (
|
||||
CREATE TABLE IF NOT EXISTS sales_dashboards (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
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,
|
||||
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
|
||||
ON app_records (tenant_key, record_kind, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS sales_dashboards_tenant_created_idx
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user