-- wave-13: reports-navigation-hub (spec 103)
-- Creates report_shortcuts table for per-user saved report views.

--> statement-breakpoint
CREATE TABLE IF NOT EXISTS report_shortcuts (
  id          UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  tenant_id   UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
  user_id     UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  name        TEXT NOT NULL,
  report_type TEXT NOT NULL CHECK (report_type IN (
                'revenue','invoices','payments','time','expenses',
                'profitability','revenue_forecast','leads','proposals',
                'ar_aging','bad_debt','audit','api_usage',
                'vat','pnl','cashflow','advance_tax','withholding',
                'bituach_leumi','uniform_format')),
  params      JSONB NOT NULL,
  created_at  TIMESTAMPTZ NOT NULL DEFAULT now()
);

--> statement-breakpoint
CREATE INDEX IF NOT EXISTS idx_report_shortcuts_user ON report_shortcuts(tenant_id, user_id, created_at DESC);
