/* Warnings: - You are about to drop the column `communityId` on the `User` table. All the data in the column will be lost. - Added the required column `ownerId` to the `Community` table without a default value. This is not possible if the table is not empty. - Added the required column `creatorId` to the `Invite` table without a default value. This is not possible if the table is not empty. - Made the column `communityId` on table `Invite` required. This step will fail if there are existing NULL values in that column. */ -- DropForeignKey ALTER TABLE "Invite" DROP CONSTRAINT "Invite_communityId_fkey"; -- DropForeignKey ALTER TABLE "User" DROP CONSTRAINT "User_communityId_fkey"; -- AlterTable ALTER TABLE "Community" ADD COLUMN "ownerId" TEXT NOT NULL; -- AlterTable ALTER TABLE "Invite" ADD COLUMN "creatorId" TEXT NOT NULL, ALTER COLUMN "communityId" SET NOT NULL; -- AlterTable ALTER TABLE "User" DROP COLUMN "communityId"; -- CreateTable CREATE TABLE "_MembersCommunitiesToUsers" ( "A" TEXT NOT NULL, "B" TEXT NOT NULL, CONSTRAINT "_MembersCommunitiesToUsers_AB_pkey" PRIMARY KEY ("A","B") ); -- CreateIndex CREATE INDEX "_MembersCommunitiesToUsers_B_index" ON "_MembersCommunitiesToUsers"("B"); -- AddForeignKey ALTER TABLE "Community" ADD CONSTRAINT "Community_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Invite" ADD CONSTRAINT "Invite_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "Community"("id") ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Invite" ADD CONSTRAINT "Invite_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_MembersCommunitiesToUsers" ADD CONSTRAINT "_MembersCommunitiesToUsers_A_fkey" FOREIGN KEY ("A") REFERENCES "Community"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_MembersCommunitiesToUsers" ADD CONSTRAINT "_MembersCommunitiesToUsers_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;