From a26e486ab53bbbb16bdbea0db50ded4e404d2c65 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 22 May 2026 16:13:28 +0200 Subject: [PATCH] chore(migration): include manual rollback.sql for PR8 multi-mentor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested against the 2026-05-07 prod dump: restore → forward → rollback restores the schema to its pre-migration state. Safe to run only BEFORE any project gets a second mentor — re-adding UNIQUE(projectId) will fail otherwise (intended safety signal). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../rollback.sql | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 prisma/migrations/20260522155652_multi_mentor_per_team/rollback.sql diff --git a/prisma/migrations/20260522155652_multi_mentor_per_team/rollback.sql b/prisma/migrations/20260522155652_multi_mentor_per_team/rollback.sql new file mode 100644 index 0000000..6110f6f --- /dev/null +++ b/prisma/migrations/20260522155652_multi_mentor_per_team/rollback.sql @@ -0,0 +1,23 @@ +-- PR8 rollback SQL (manual, only safe BEFORE any project has >1 mentor) +-- Reverses 20260522155652_multi_mentor_per_team + +-- MentorChangeRequest: drop new table + enum +DROP TABLE IF EXISTS "MentorChangeRequest"; +DROP TYPE IF EXISTS "MentorChangeRequestStatus"; + +-- MentorFile: drop projectId scope + restore mentorAssignmentId as required Cascade +ALTER TABLE "MentorFile" DROP CONSTRAINT IF EXISTS "MentorFile_projectId_fkey"; +DROP INDEX IF EXISTS "MentorFile_projectId_idx"; +ALTER TABLE "MentorFile" DROP COLUMN IF EXISTS "projectId"; +-- Restoring NOT NULL is safe only if no rows have NULL mentorAssignmentId (true unless multi-mentor assignments were dropped post-migration) +ALTER TABLE "MentorFile" ALTER COLUMN "mentorAssignmentId" SET NOT NULL; +ALTER TABLE "MentorFile" DROP CONSTRAINT IF EXISTS "MentorFile_mentorAssignmentId_fkey"; +ALTER TABLE "MentorFile" ADD CONSTRAINT "MentorFile_mentorAssignmentId_fkey" + FOREIGN KEY ("mentorAssignmentId") REFERENCES "MentorAssignment"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- MentorAssignment: restore projectId @unique + drop new fields +DROP INDEX IF EXISTS "MentorAssignment_projectId_mentorId_key"; +DROP INDEX IF EXISTS "MentorAssignment_projectId_idx"; +ALTER TABLE "MentorAssignment" DROP COLUMN IF EXISTS "notificationSentAt"; +-- Re-adding UNIQUE will FAIL if any project has >1 mentor (intended safety signal) +ALTER TABLE "MentorAssignment" ADD CONSTRAINT "MentorAssignment_projectId_key" UNIQUE ("projectId");