Files
evig/scripts/db/migrations/084_missing_performance_indexes.sql
Mao NakamotoandCursor 199e686351 feat(e2e,ci): workshop proposal journey + migration drift gate
Add dual-persona E2E for workshop propose/approve/reject (#61–62) and wire it
into post-deploy inventory. CI now replays all migrations on pgvector Postgres
with idempotent guards so fresh-DB apply matches prod evolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 16:10:39 +02:00

30 lines
1.1 KiB
SQL

-- Migration 084: Performance indexes the audit flagged as missing
-- Idempotent: skip when target table/column missing on fresh CI databases.
DO $$
BEGIN
IF to_regclass('public.notifications') IS NOT NULL THEN
CREATE INDEX IF NOT EXISTS idx_notifications_user_unread_recent
ON notifications(user_id, is_read, created_at DESC);
END IF;
IF to_regclass('public.pool_memberships') IS NOT NULL THEN
CREATE INDEX IF NOT EXISTS idx_pool_memberships_pool_status
ON pool_memberships(pool_id, status);
END IF;
IF to_regclass('public.inventory_items') IS NOT NULL THEN
CREATE INDEX IF NOT EXISTS idx_inventory_items_status_assignee
ON inventory_items(status, assigned_to);
END IF;
IF to_regclass('public.fundraising_foundations') IS NOT NULL AND EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'fundraising_foundations' AND column_name = 'archived'
) THEN
CREATE INDEX IF NOT EXISTS idx_fundraising_foundations_active_recent
ON fundraising_foundations(created_at DESC)
WHERE archived = false;
END IF;
END $$;