Added migration for current db schema
parent
a231ee6c0d
commit
c66af610e5
|
@ -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;
|
Loading…
Reference in New Issue