76 lines
3.9 KiB
SQL
76 lines
3.9 KiB
SQL
-- R-P6B-β (AD-2): forward-only removal of the generic Entity-Builder.
|
|
--
|
|
-- Earlier migrations create the entity-builder objects; this migration removes
|
|
-- them so the migration history reconciles with the post-removal Prisma schema
|
|
-- (entityBuilder.prisma was deleted on the R-P6B-β branch). Every statement is
|
|
-- guarded with IF EXISTS, so `prisma migrate deploy` stays reproducible against
|
|
-- an empty database (create-then-drop) and idempotent on re-runs.
|
|
--
|
|
-- KEPT on purpose: entityLinks.prisma (FileEntityLink etc.) — typed polymorphic
|
|
-- links, unrelated to the generic builder.
|
|
--
|
|
-- OUT OF SCOPE (left untouched): `prisma migrate diff` also reports pre-existing
|
|
-- migration-vs-schema drift on AppsEngine tables (App / AppSyncItem / AppSyncRun
|
|
-- / AppSyncRunLog / DataConnection). That drift exists in the schema both before
|
|
-- and after this change and is NOT an entity-builder concern, so it is not
|
|
-- addressed here.
|
|
--
|
|
-- ---------------------------------------------------------------------------
|
|
-- INVERSE / ROLLBACK (forward-only project — reference only, NOT auto-applied):
|
|
-- This migration is destructive. There are no real tenants and no
|
|
-- entity-builder data to preserve (product decision, 2026-06-30), so no data
|
|
-- export is performed. To recreate the entity-builder you would restore the
|
|
-- pre-removal DDL from git: the 36 tables from
|
|
-- git show <pre-β>:prisma/schema/entityBuilder.prisma
|
|
-- plus the dropped FK columns Log.rowId / Log.commentId / Permission.entityId
|
|
-- / OutboundEmail.contactRowId and their foreign keys. (<pre-β> = the commit
|
|
-- before "refactor(R-P6B-β): generischen Entity-Builder vollstaendig entfernen".)
|
|
-- ---------------------------------------------------------------------------
|
|
|
|
-- 1) Drop entity-builder foreign-key columns on kept tables. Dropping a column
|
|
-- also drops its own foreign-key constraint, so no explicit constraint drop
|
|
-- is required here.
|
|
ALTER TABLE "Log" DROP COLUMN IF EXISTS "rowId";
|
|
ALTER TABLE "Log" DROP COLUMN IF EXISTS "commentId";
|
|
ALTER TABLE "Permission" DROP COLUMN IF EXISTS "entityId";
|
|
ALTER TABLE "OutboundEmail" DROP COLUMN IF EXISTS "contactRowId";
|
|
|
|
-- 2) Drop the 36 entity-builder tables. CASCADE clears the foreign keys between
|
|
-- them (and any remaining references into them), so the order is irrelevant.
|
|
DROP TABLE IF EXISTS "ApiKeyEntity" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityGroupConfigurationRow" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityGroupConfiguration" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityGroupEntity" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityGroup" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityRelationship" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityTag" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityTemplate" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityTenantUserPermission" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityViewFilter" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityViewProperty" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityViewSort" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityView" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityWebhookLog" CASCADE;
|
|
DROP TABLE IF EXISTS "EntityWebhook" CASCADE;
|
|
DROP TABLE IF EXISTS "FormulaComponentLog" CASCADE;
|
|
DROP TABLE IF EXISTS "FormulaComponent" CASCADE;
|
|
DROP TABLE IF EXISTS "FormulaLog" CASCADE;
|
|
DROP TABLE IF EXISTS "Formula" CASCADE;
|
|
DROP TABLE IF EXISTS "PropertyAttribute" CASCADE;
|
|
DROP TABLE IF EXISTS "PropertyOption" CASCADE;
|
|
DROP TABLE IF EXISTS "Property" CASCADE;
|
|
DROP TABLE IF EXISTS "RowCommentReaction" CASCADE;
|
|
DROP TABLE IF EXISTS "RowComment" CASCADE;
|
|
DROP TABLE IF EXISTS "RowMedia" CASCADE;
|
|
DROP TABLE IF EXISTS "RowPermission" CASCADE;
|
|
DROP TABLE IF EXISTS "RowRelationship" CASCADE;
|
|
DROP TABLE IF EXISTS "RowTag" CASCADE;
|
|
DROP TABLE IF EXISTS "RowTask" CASCADE;
|
|
DROP TABLE IF EXISTS "RowValueMultiple" CASCADE;
|
|
DROP TABLE IF EXISTS "RowValueRange" CASCADE;
|
|
DROP TABLE IF EXISTS "RowValue" CASCADE;
|
|
DROP TABLE IF EXISTS "Row" CASCADE;
|
|
DROP TABLE IF EXISTS "TenantSettingsRow" CASCADE;
|
|
DROP TABLE IF EXISTS "SampleCustomEntity" CASCADE;
|
|
DROP TABLE IF EXISTS "Entity" CASCADE;
|