Added migration for current db schema

pull/261/head
nicolas 2021-06-13 15:37:13 +02:00
parent a231ee6c0d
commit c66af610e5
1 changed files with 26 additions and 0 deletions

View File

@ -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;