cal.pub0.org/prisma/migrations/20210605225044_init/migration.sql

51 lines
1.2 KiB
MySQL
Raw Normal View History

-- CreateTable
CREATE TABLE "EventType" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
"locations" JSONB,
"length" INTEGER NOT NULL,
"hidden" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Credential" (
"id" SERIAL NOT NULL,
"type" TEXT NOT NULL,
"key" JSONB NOT NULL,
"userId" INTEGER,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"username" TEXT,
"name" TEXT,
"email" TEXT,
"password" TEXT,
"bio" TEXT,
"avatar" TEXT,
"timeZone" TEXT NOT NULL DEFAULT E'Europe/London',
"weekStart" TEXT DEFAULT E'Sunday',
"startTime" INTEGER NOT NULL DEFAULT 0,
"endTime" INTEGER NOT NULL DEFAULT 1440,
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "users.email_unique" ON "users"("email");
-- AddForeignKey
ALTER TABLE "EventType" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Credential" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;