calcom/packages/prisma/migrations/20210605225507_added_bookings/migration.sql
Omar López fe35cf6570
Extract prisma to it's own package (#1823)
* Moved prisma to packages

* Add missing prisma configs

* Extracts common libs and types

* Build and pipeline fixes

* Adds missing package

* Prisma scripts cleanup

* Updates lint staged

* Type fixes

* Sort imports

* Updates yarn lock file

* Fixes for yarn dx

* Revert "Sort imports"

This reverts commit 076109decab9b9ba307fc03696c3b0da5c4896f3.

* Formatting

* Prevent double TS version

* Fix conflict

* Extracted e2e configs
2022-02-15 13:30:52 -07:00

48 lines
1.3 KiB
SQL

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