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");