MOPC-App/prisma/migrations/20260214000000_simplify_rou.../migration.sql

29 lines
1.2 KiB
SQL

-- Simplify RoutingMode enum: remove POST_MAIN, rename PARALLEL → SHARED
-- Drop RoutingRule table (routing is now handled via award assignment)
-- 1. Update existing PARALLEL values to SHARED, POST_MAIN to SHARED
UPDATE "Track" SET "routingMode" = 'PARALLEL' WHERE "routingMode" = 'POST_MAIN';
-- 2. Rename PARALLEL → SHARED in the enum
ALTER TYPE "RoutingMode" RENAME VALUE 'PARALLEL' TO 'SHARED';
-- 3. Remove POST_MAIN from the enum
-- PostgreSQL doesn't support DROP VALUE directly, so we recreate the enum
-- Since we already converted POST_MAIN values to PARALLEL (now SHARED), this is safe
-- Create new enum without POST_MAIN
-- Actually, since we already renamed PARALLEL to SHARED and converted POST_MAIN rows,
-- we just need to remove the POST_MAIN value. PostgreSQL 13+ doesn't support dropping
-- enum values natively, but since all rows are already migrated, we can:
CREATE TYPE "RoutingMode_new" AS ENUM ('SHARED', 'EXCLUSIVE');
ALTER TABLE "Track"
ALTER COLUMN "routingMode" TYPE "RoutingMode_new"
USING ("routingMode"::text::"RoutingMode_new");
DROP TYPE "RoutingMode";
ALTER TYPE "RoutingMode_new" RENAME TO "RoutingMode";
-- 4. Drop the RoutingRule table (no longer needed)
DROP TABLE IF EXISTS "RoutingRule";