From c66af610e5e8c2d0cacba8611aeea08fdf178a2d Mon Sep 17 00:00:00 2001 From: nicolas Date: Sun, 13 Jun 2021 15:37:13 +0200 Subject: [PATCH] Added migration for current db schema --- .../migration.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 prisma/migrations/20210613133618_add_team_membership_verification/migration.sql diff --git a/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql b/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql new file mode 100644 index 0000000000..cf9aa22320 --- /dev/null +++ b/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql @@ -0,0 +1,26 @@ +-- CreateEnum +CREATE TYPE "MembershipRole" AS ENUM ('MEMBER', 'OWNER'); + +-- CreateTable +CREATE TABLE "Team" ( + "id" SERIAL NOT NULL, + "name" TEXT, + + PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Membership" ( + "teamId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL, + "accepted" BOOLEAN NOT NULL DEFAULT false, + "role" "MembershipRole" NOT NULL, + + PRIMARY KEY ("userId","teamId") +); + +-- AddForeignKey +ALTER TABLE "Membership" ADD FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Membership" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;