Scheduling infrastructure for absolutely everyone.
Use migrations to introduce new tables for bookings
nicolasbc7ac136cc36
diff --git a/prisma/migrations/20210605225044_init/migration.sql b/prisma/migrations/20210605225044_init/migration.sqlnew file mode 100644index 00000000000..af13be70a73--- /dev/null+++ b/prisma/migrations/20210605225044_init/migration.sql@@ -0,0 +1,50 @@+-- 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;diff --git a/prisma/migrations/20210605225507_added_bookings/migration.sql b/prisma/migrations/20210605225507_added_bookings/migration.sqlnew file mode 100644index 00000000000..da362496b0b--- /dev/null+++ b/prisma/migrations/20210605225507_added_bookings/migration.sql@@ -0,0 +1,48 @@+-- CreateTable+CREATE TABLE "BookingReference" (+ "id" SERIAL NOT NULL,+ "type" TEXT NOT NULL,+ "uid" TEXT NOT NULL,+ "bookingId" INTEGER,++ PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "Attendee" (+ "id" SERIAL NOT NULL,+ "email" TEXT NOT NULL,+ "name" TEXT NOT NULL,+ "timeZone" TEXT NOT NULL,+ "bookingId" INTEGER,++ PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "Booking" (+ "id" SERIAL NOT NULL,+ "uid" TEXT NOT NULL,+ "userId" INTEGER,+ "eventTypeId" INTEGER,+ "title" TEXT NOT NULL,+ "description" TEXT,+ "startTime" TIMESTAMP(3) NOT NULL,+ "endTime" TIMESTAMP(3) NOT NULL,+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "updatedAt" TIMESTAMP(3),++ PRIMARY KEY ("id")+);++-- AddForeignKey+ALTER TABLE "Attendee" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Booking" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Booking" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "BookingReference" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.tomlnew file mode 100644index 00000000000..fbffa92c2bb--- /dev/null+++ b/prisma/migrations/migration_lock.toml@@ -0,0 +1,3 @@+# Please do not edit this file manually+# It should be added in your version-control system (i.e. Git)+provider = "postgresql"\ No newline at end of filediff --git a/prisma/schema.prisma b/prisma/schema.prismaindex 69b586d2293..aa58d8a963d 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -20,6 +20,7 @@ model EventType {hidden Boolean @default(false)user User? @relation(fields: [userId], references: [id])userId Int?+ bookings Booking[]}model Credential {@@ -45,5 +46,43 @@ model User {createdDate DateTime @default(now()) @map(name: "created")eventTypes EventType[]credentials Credential[]+ bookings Booking[]@@map(name: "users")+}++model BookingReference {+ id Int @default(autoincrement()) @id+ type String+ uid String+ booking Booking? @relation(fields: [bookingId], references: [id])+ bookingId Int?+}++model Attendee {+ id Int @default(autoincrement()) @id+ email String+ name String+ timeZone String+ booking Booking? @relation(fields: [bookingId], references: [id])+ bookingId Int?+}++model Booking {+ id Int @default(autoincrement()) @id+ uid String+ user User? @relation(fields: [userId], references: [id])+ userId Int?+ references BookingReference[]+ eventType EventType? @relation(fields: [eventTypeId], references: [id])+ eventTypeId Int?++ title String+ description String?+ startTime DateTime+ endTime DateTime++ attendees Attendee[]++ createdAt DateTime @default(now())+ updatedAt DateTime?}\ No newline at end of file