25 lines
1.4 KiB
SQL
25 lines
1.4 KiB
SQL
-- Retain the legacy subscription artifacts as externally managed data.
|
|
--
|
|
-- SubscriptionLevel and ProclamationCategorySubscriptionLevel are no longer
|
|
-- modeled by the application. They are declared as external tables in
|
|
-- prisma.config.ts so Prisma Migrate ignores them entirely and never drops
|
|
-- them (production may not own these tables, and their data is kept for
|
|
-- recovery).
|
|
--
|
|
-- This migration only touches Prisma-managed tables to decouple them from the
|
|
-- legacy FK. It is intentionally idempotent so it applies cleanly to
|
|
-- production (columns present, NOT NULL, FK present), a fresh database built
|
|
-- from migration history, and development databases that already removed the
|
|
-- legacy objects.
|
|
|
|
-- Ensure the legacy columns exist. On databases built from migration history
|
|
-- these already exist; this re-adds them on environments that dropped them.
|
|
ALTER TABLE "Proclamation" ADD COLUMN IF NOT EXISTS "subscriptionLevelId" INTEGER;
|
|
ALTER TABLE "LicenseKey" ADD COLUMN IF NOT EXISTS "level" TEXT;
|
|
|
|
-- Decouple from SubscriptionLevel: drop the FK and relax NOT NULL so the
|
|
-- application can keep inserting rows without a legacy subscription value.
|
|
ALTER TABLE "Proclamation" DROP CONSTRAINT IF EXISTS "Proclamation_subscriptionLevelId_fkey";
|
|
ALTER TABLE "Proclamation" ALTER COLUMN "subscriptionLevelId" DROP NOT NULL;
|
|
ALTER TABLE "LicenseKey" ALTER COLUMN "level" DROP NOT NULL;
|