wasp/examples/waspello/migrations/20211002184633_added_waspello_entities/migration.sql
2021-10-11 14:03:03 +02:00

42 lines
1004 B
SQL

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "List" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"pos" DOUBLE PRECISION NOT NULL,
"userId" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Card" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"pos" DOUBLE PRECISION NOT NULL,
"listId" INTEGER NOT NULL,
"authorId" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
-- AddForeignKey
ALTER TABLE "List" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Card" ADD FOREIGN KEY ("listId") REFERENCES "List"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Card" ADD FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;