MOPC-App/prisma/migrations/20260217000000_schema_recon.../migration.sql

20 lines
1.1 KiB
SQL

-- =============================================================================
-- Schema Reconciliation: Fill remaining gaps between migrations and schema.prisma
-- =============================================================================
-- All statements are idempotent (safe to re-run on any database state).
-- 1. ConflictOfInterest: add standalone hasConflict index (schema has @@index([hasConflict]))
-- Migration 20260205223133 only created composite (roundId, hasConflict) index.
CREATE INDEX IF NOT EXISTS "ConflictOfInterest_hasConflict_idx" ON "ConflictOfInterest"("hasConflict");
-- 2. Ensure ConflictOfInterest.roundId is nullable (schema says String?)
-- Pipeline migration (20260213) makes it nullable, but guard for safety.
DO $$ BEGIN
ALTER TABLE "ConflictOfInterest" ALTER COLUMN "roundId" DROP NOT NULL;
EXCEPTION WHEN others THEN NULL;
END $$;
-- 3. Drop stale composite index that no longer matches schema
-- Schema only has @@index([hasConflict]) and @@index([userId]), not (roundId, hasConflict).
DROP INDEX IF EXISTS "ConflictOfInterest_roundId_hasConflict_idx";