ceo-api/drizzle/0009_financial_intelligence.sql

26 lines
980 B
SQL

-- Migration 0009: Financial Intelligence — market signals table
-- Stores macro/FX/rates/news signals ingested from n8n (World Bank, IMF, Eurostat, DBnomics)
CREATE TABLE IF NOT EXISTS "financial_signals" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
"tenant_id" uuid,
"category" text NOT NULL DEFAULT 'macro',
"region" text NOT NULL DEFAULT 'global',
"niche" text,
"source" text NOT NULL,
"indicator_code" text,
"title" text NOT NULL,
"summary" text NOT NULL,
"raw_value" numeric(18, 4),
"change_percent" numeric(10, 4),
"unit" text,
"severity" text NOT NULL DEFAULT 'info',
"published_at" timestamp NOT NULL DEFAULT now(),
"expires_at" timestamp,
"created_at" timestamp NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS "financial_signals_published_idx"
ON "financial_signals" ("category", "published_at" DESC);
CREATE INDEX IF NOT EXISTS "financial_signals_tenant_idx"
ON "financial_signals" ("tenant_id", "published_at" DESC);