cal.pub0.org/prisma/migrations/20210613133618_add_team_mem.../migration.sql

27 lines
674 B
SQL

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