first commit
This commit is contained in:
1
calcom/packages/prisma/.env
Symbolic link
1
calcom/packages/prisma/.env
Symbolic link
@@ -0,0 +1 @@
|
||||
../../.env
|
||||
42
calcom/packages/prisma/auto-migrations.ts
Normal file
42
calcom/packages/prisma/auto-migrations.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import dotEnv from "dotenv";
|
||||
import { exec as execCb } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
import { isPrismaAvailableCheck } from "./is-prisma-available-check";
|
||||
|
||||
dotEnv.config({ path: "../../.env" });
|
||||
|
||||
const exec = promisify(execCb);
|
||||
|
||||
/**
|
||||
* TODO: re-write this when Prisma.io gets a programmatic migration API
|
||||
* Thanks to @olalonde for the idea.
|
||||
* @see https://github.com/prisma/prisma/issues/4703#issuecomment-1447354363
|
||||
*/
|
||||
async function main(): Promise<void> {
|
||||
if (!process.env.DATABASE_URL) {
|
||||
console.info("No DATABASE_URL found, skipping migrations");
|
||||
return;
|
||||
}
|
||||
if (!process.env.DATABASE_DIRECT_URL) {
|
||||
console.info("No DATABASE_DIRECT_URL found, skipping migrations");
|
||||
return;
|
||||
}
|
||||
if (!(await isPrismaAvailableCheck())) {
|
||||
console.info("Prisma can't be initialized, skipping migrations");
|
||||
return;
|
||||
}
|
||||
// throws an error if migration fails
|
||||
const { stdout, stderr } = await exec("yarn prisma migrate deploy", {
|
||||
env: {
|
||||
...process.env,
|
||||
},
|
||||
});
|
||||
console.log(stdout);
|
||||
console.error(stderr);
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e.stdout || e.stderr || e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
1
calcom/packages/prisma/client/index.d.ts
vendored
Normal file
1
calcom/packages/prisma/client/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "../../../node_modules/.prisma/client/index.d";
|
||||
1
calcom/packages/prisma/client/index.js
Normal file
1
calcom/packages/prisma/client/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export * from "../../../node_modules/.prisma/client";
|
||||
35
calcom/packages/prisma/delete-app.ts
Normal file
35
calcom/packages/prisma/delete-app.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import prisma from ".";
|
||||
|
||||
// TODO: Put some restrictions here to run it on local DB only.
|
||||
// Production DB currently doesn't support app deletion
|
||||
async function main() {
|
||||
const appId = process.argv[2];
|
||||
try {
|
||||
await prisma.app.delete({
|
||||
where: {
|
||||
slug: appId,
|
||||
},
|
||||
});
|
||||
await prisma.credential.deleteMany({
|
||||
where: {
|
||||
appId: appId,
|
||||
},
|
||||
});
|
||||
console.log(`Deleted app from DB: '${appId}'`);
|
||||
} catch (e) {
|
||||
if (e.code === "P2025") {
|
||||
console.log(`App '${appId}' already deleted from DB`);
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
27
calcom/packages/prisma/docker-compose.yml
Normal file
27
calcom/packages/prisma/docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
# this file is a helper to run Cal.com locally
|
||||
# starts a postgres instance on port 5450 to use as a local db
|
||||
version: "3.6"
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13
|
||||
ports:
|
||||
- "5450:5432" # expose pg on port 5450 to not collide with pg from elswhere
|
||||
restart: always
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_DB: "cal-saml"
|
||||
POSTGRES_PASSWORD: ""
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
postgres_is_ready:
|
||||
image: postgres
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
db_data:
|
||||
37
calcom/packages/prisma/enum-generator.ts
Normal file
37
calcom/packages/prisma/enum-generator.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { generatorHandler } from "@prisma/generator-helper";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
const header = `// This file was generated by a custom prisma generator, do not edit manually.\n`;
|
||||
|
||||
generatorHandler({
|
||||
onManifest() {
|
||||
return {
|
||||
defaultOutput: "./enums/index.ts",
|
||||
prettyName: "Prisma Enum Generator",
|
||||
};
|
||||
},
|
||||
async onGenerate(options) {
|
||||
const enums = options.dmmf.datamodel.enums;
|
||||
|
||||
const output = enums.map((e) => {
|
||||
let enumString = `export const ${e.name} = {\n`;
|
||||
e.values.forEach(({ name: value }) => {
|
||||
enumString += ` ${value}: "${value}",\n`;
|
||||
});
|
||||
enumString += `} as const;\n\n`;
|
||||
enumString += `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];\n`;
|
||||
|
||||
return enumString;
|
||||
});
|
||||
|
||||
const outputFile = options.generator.output;
|
||||
if (!outputFile || !outputFile.value) {
|
||||
throw new Error("No output file specified");
|
||||
}
|
||||
|
||||
const outputPath = path.resolve(outputFile.value);
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await fs.writeFile(outputPath, header + output.join("\n"), "utf-8");
|
||||
},
|
||||
});
|
||||
38
calcom/packages/prisma/extensions/booking-idempotency-key.ts
Normal file
38
calcom/packages/prisma/extensions/booking-idempotency-key.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { v5 as uuidv5 } from "uuid";
|
||||
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
export function bookingIdempotencyKeyExtension() {
|
||||
return Prisma.defineExtension({
|
||||
query: {
|
||||
booking: {
|
||||
async create({ args, query }) {
|
||||
const uniqueEmailJoinInput: string[] = [];
|
||||
if (args.data.attendees?.create && !Array.isArray(args.data.attendees?.create)) {
|
||||
uniqueEmailJoinInput.push(args.data.attendees?.create.email);
|
||||
}
|
||||
if (args.data.attendees?.createMany && Array.isArray(args.data.attendees?.createMany.data)) {
|
||||
uniqueEmailJoinInput.push(...args.data.attendees?.createMany.data.map((record) => record.email));
|
||||
}
|
||||
const idempotencyKey = uuidv5(
|
||||
`${
|
||||
args.data.eventType?.connect?.id
|
||||
}.${args.data.startTime.valueOf()}.${args.data.endTime.valueOf()}.${uniqueEmailJoinInput.join(
|
||||
","
|
||||
)}`,
|
||||
uuidv5.URL
|
||||
);
|
||||
args.data.idempotencyKey = idempotencyKey;
|
||||
return query(args);
|
||||
},
|
||||
async update({ args, query }) {
|
||||
if (args.data.status === BookingStatus.CANCELLED || args.data.status === BookingStatus.REJECTED) {
|
||||
args.data.idempotencyKey = null;
|
||||
}
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import type { DefaultArgs, InternalArgs } from "@prisma/client/runtime/library";
|
||||
|
||||
export function excludePendingPaymentsExtension() {
|
||||
return Prisma.defineExtension({
|
||||
query: {
|
||||
team: {
|
||||
async findUnique({ args, query }) {
|
||||
return excludePendingPayments(args, query);
|
||||
},
|
||||
async findFirst({ args, query }) {
|
||||
return excludePendingPayments(args, query);
|
||||
},
|
||||
async findMany({ args, query }) {
|
||||
return excludePendingPayments(args, query);
|
||||
},
|
||||
async findUniqueOrThrow({ args, query }) {
|
||||
return excludePendingPayments(args, query);
|
||||
},
|
||||
async findFirstOrThrow({ args, query }) {
|
||||
return excludePendingPayments(args, query);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function excludePendingPayments(
|
||||
args:
|
||||
| Prisma.TeamFindUniqueArgs<InternalArgs & DefaultArgs>
|
||||
| Prisma.TeamFindFirstArgs<InternalArgs & DefaultArgs>
|
||||
| Prisma.TeamFindManyArgs<InternalArgs & DefaultArgs>
|
||||
| Prisma.TeamFindUniqueOrThrowArgs<InternalArgs & DefaultArgs>
|
||||
| Prisma.TeamFindFirstOrThrowArgs<InternalArgs & DefaultArgs>,
|
||||
query: <T>(args: T) => Promise<unknown>
|
||||
) {
|
||||
args.where = args.where || {};
|
||||
if (args.where.pendingPayment === undefined) {
|
||||
args.where.pendingPayment = false;
|
||||
}
|
||||
return query(args);
|
||||
}
|
||||
58
calcom/packages/prisma/index.ts
Normal file
58
calcom/packages/prisma/index.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { PrismaClient as PrismaClientWithoutExtension } from "@prisma/client";
|
||||
import { withAccelerate } from "@prisma/extension-accelerate";
|
||||
|
||||
import { bookingIdempotencyKeyExtension } from "./extensions/booking-idempotency-key";
|
||||
import { excludePendingPaymentsExtension } from "./extensions/exclude-pending-payment-teams";
|
||||
import { bookingReferenceMiddleware } from "./middleware";
|
||||
|
||||
const prismaOptions: Prisma.PrismaClientOptions = {};
|
||||
|
||||
const globalForPrisma = global as unknown as {
|
||||
prismaWithoutClientExtensions: PrismaClientWithoutExtension;
|
||||
prismaWithClientExtensions: PrismaClientWithExtensions;
|
||||
};
|
||||
|
||||
if (!!process.env.NEXT_PUBLIC_DEBUG) prismaOptions.log = ["query", "error", "warn"];
|
||||
|
||||
// Prevents flooding with idle connections
|
||||
const prismaWithoutClientExtensions =
|
||||
globalForPrisma.prismaWithoutClientExtensions || new PrismaClientWithoutExtension(prismaOptions);
|
||||
|
||||
export const customPrisma = (options?: Prisma.PrismaClientOptions) =>
|
||||
new PrismaClientWithoutExtension({ ...prismaOptions, ...options })
|
||||
.$extends(excludePendingPaymentsExtension())
|
||||
.$extends(bookingIdempotencyKeyExtension())
|
||||
.$extends(withAccelerate());
|
||||
|
||||
// If any changed on middleware server restart is required
|
||||
// TODO: Migrate it to $extends
|
||||
bookingReferenceMiddleware(prismaWithoutClientExtensions);
|
||||
|
||||
// FIXME: Due to some reason, there are types failing in certain places due to the $extends. Fix it and then enable it
|
||||
// Specifically we get errors like `Type 'string | Date | null | undefined' is not assignable to type 'Exact<string | Date | null | undefined, string | Date | null | undefined>'`
|
||||
const prismaWithClientExtensions = prismaWithoutClientExtensions
|
||||
.$extends(excludePendingPaymentsExtension())
|
||||
.$extends(bookingIdempotencyKeyExtension())
|
||||
.$extends(withAccelerate());
|
||||
|
||||
export const prisma = globalForPrisma.prismaWithClientExtensions || prismaWithClientExtensions;
|
||||
|
||||
// This prisma instance is meant to be used only for READ operations.
|
||||
// If self hosting, feel free to leave INSIGHTS_DATABASE_URL as empty and `readonlyPrisma` will default to `prisma`.
|
||||
export const readonlyPrisma = process.env.INSIGHTS_DATABASE_URL
|
||||
? customPrisma({
|
||||
datasources: { db: { url: process.env.INSIGHTS_DATABASE_URL } },
|
||||
})
|
||||
: prisma;
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
globalForPrisma.prismaWithoutClientExtensions = prismaWithoutClientExtensions;
|
||||
globalForPrisma.prismaWithClientExtensions = prisma;
|
||||
}
|
||||
|
||||
type PrismaClientWithExtensions = typeof prismaWithClientExtensions;
|
||||
export type PrismaClient = PrismaClientWithExtensions;
|
||||
export default prisma;
|
||||
|
||||
export * from "./selects";
|
||||
17
calcom/packages/prisma/is-prisma-available-check.ts
Normal file
17
calcom/packages/prisma/is-prisma-available-check.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
import prisma from ".";
|
||||
|
||||
export async function isPrismaAvailableCheck() {
|
||||
try {
|
||||
await prisma.$queryRaw`SELECT 1`;
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Prisma.PrismaClientInitializationError) {
|
||||
// Database might not available at build time.
|
||||
return false;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
calcom/packages/prisma/middleware/bookingReference.ts
Normal file
50
calcom/packages/prisma/middleware/bookingReference.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { PrismaClient } from "@prisma/client";
|
||||
|
||||
function middleware(prisma: PrismaClient) {
|
||||
/***********************************/
|
||||
/* SOFT DELETE MIDDLEWARE */
|
||||
/***********************************/
|
||||
prisma.$use(async (params, next) => {
|
||||
// Check incoming query type
|
||||
|
||||
if (params.model === "BookingReference") {
|
||||
if (params.action === "delete") {
|
||||
// Delete queries
|
||||
// Change action to an update
|
||||
params.action = "update";
|
||||
params.args["data"] = { deleted: true };
|
||||
}
|
||||
if (params.action === "deleteMany") {
|
||||
// Delete many queries
|
||||
params.action = "updateMany";
|
||||
if (params.args.data !== undefined) {
|
||||
params.args.data["deleted"] = true;
|
||||
} else {
|
||||
params.args["data"] = { deleted: true };
|
||||
}
|
||||
}
|
||||
if (params.action === "findUnique") {
|
||||
// Change to findFirst - you cannot filter
|
||||
// by anything except ID / unique with findUnique
|
||||
params.action = "findFirst";
|
||||
// Add 'deleted' filter
|
||||
// ID filter maintained
|
||||
params.args.where["deleted"] = null;
|
||||
}
|
||||
if (params.action === "findMany" || params.action === "findFirst") {
|
||||
// Find many queries
|
||||
if (params.args.where !== undefined) {
|
||||
if (params.args.where.deleted === undefined) {
|
||||
// Exclude deleted records if they have not been explicitly requested
|
||||
params.args.where["deleted"] = null;
|
||||
}
|
||||
} else {
|
||||
params.args["where"] = { deleted: null };
|
||||
}
|
||||
}
|
||||
}
|
||||
return next(params);
|
||||
});
|
||||
}
|
||||
|
||||
export default middleware;
|
||||
1
calcom/packages/prisma/middleware/index.ts
Normal file
1
calcom/packages/prisma/middleware/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as bookingReferenceMiddleware } from "./bookingReference";
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[uid]` on the table `Booking` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Booking.uid_unique" ON "Booking"("uid");
|
||||
@@ -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;
|
||||
@@ -0,0 +1,11 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "SelectedCalendar" (
|
||||
"userId" INTEGER NOT NULL,
|
||||
"integration" TEXT NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY ("userId","integration","externalId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "eventName" TEXT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "bufferTime" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,20 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "emailVerified" TIMESTAMP(3);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "VerificationRequest" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "VerificationRequest.token_unique" ON "VerificationRequest"("token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "VerificationRequest.identifier_token_unique" ON "VerificationRequest"("identifier", "token");
|
||||
@@ -0,0 +1,13 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "EventTypeCustomInput" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"eventTypeId" INTEGER NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"required" BOOLEAN NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,10 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ResetPasswordRequest" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "hideBranding" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,22 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "timeZone" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Availability" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"label" TEXT,
|
||||
"userId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
"days" INTEGER[],
|
||||
"startTime" INTEGER NOT NULL,
|
||||
"endTime" INTEGER NOT NULL,
|
||||
"date" DATE,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "theme" TEXT;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "periodCountCalendarDays" BOOLEAN,
|
||||
ADD COLUMN "periodDays" INTEGER,
|
||||
ADD COLUMN "periodEndDate" TIMESTAMP(3),
|
||||
ADD COLUMN "periodStartDate" TIMESTAMP(3),
|
||||
ADD COLUMN "periodType" TEXT DEFAULT E'unlimited';
|
||||
@@ -0,0 +1,6 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "confirmed" BOOLEAN NOT NULL DEFAULT true,
|
||||
ADD COLUMN "rejected" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "requiresConfirmation" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,13 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ReminderType" AS ENUM ('PENDING_BOOKING_CONFIRMATION');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ReminderMail" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"referenceId" INTEGER NOT NULL,
|
||||
"reminderType" "ReminderType" NOT NULL,
|
||||
"elapsedMinutes" INTEGER NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "minimumBookingNotice" INTEGER NOT NULL DEFAULT 120;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "location" TEXT;
|
||||
@@ -0,0 +1,35 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PaymentType" AS ENUM ('STRIPE');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "paid" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "currency" TEXT NOT NULL DEFAULT E'usd',
|
||||
ADD COLUMN "price" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Payment" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"uid" TEXT NOT NULL,
|
||||
"type" "PaymentType" NOT NULL,
|
||||
"bookingId" INTEGER NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"fee" INTEGER NOT NULL,
|
||||
"currency" TEXT NOT NULL,
|
||||
"success" BOOLEAN NOT NULL,
|
||||
"refunded" BOOLEAN NOT NULL,
|
||||
"data" JSONB NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Payment.uid_unique" ON "Payment"("uid");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Payment.externalId_unique" ON "Payment"("externalId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" ADD COLUMN "slug" TEXT;
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EventTypeCustomInputType" AS ENUM ('text', 'textLong', 'number', 'bool');
|
||||
|
||||
--- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" RENAME COLUMN "type" TO "type_old";
|
||||
ALTER TABLE "EventTypeCustomInput" ADD COLUMN "type" "EventTypeCustomInputType";
|
||||
|
||||
-- UpdateTable
|
||||
UPDATE "EventTypeCustomInput" SET "type" = CAST( "type_old" AS "EventTypeCustomInputType" );
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" ALTER COLUMN "type" SET NOT NULL;
|
||||
ALTER TABLE "EventTypeCustomInput" DROP COLUMN "type_old";
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" ADD COLUMN "placeholder" TEXT NOT NULL DEFAULT E'';
|
||||
@@ -0,0 +1,4 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" ADD COLUMN "bio" TEXT,
|
||||
ADD COLUMN "hideBranding" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "logo" TEXT;
|
||||
@@ -0,0 +1,19 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "completedOnboarding" BOOLEAN DEFAULT false;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Schedule" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
"title" TEXT,
|
||||
"freeBusyTimes" JSONB,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[slug]` on the table `Team` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Team.slug_unique" ON "Team"("slug");
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[userId,slug]` on the table `EventType` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventType.userId_slug_unique" ON "EventType"("userId", "slug");
|
||||
@@ -0,0 +1,5 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "UserPlan" AS ENUM ('FREE', 'TRIAL', 'PRO');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "plan" "UserPlan" NOT NULL DEFAULT E'PRO';
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[username]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users.username_unique" ON "users"("username");
|
||||
@@ -0,0 +1,5 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "BookingStatus" AS ENUM ('cancelled', 'accepted', 'rejected', 'pending');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "status" "BookingStatus" NOT NULL DEFAULT E'accepted';
|
||||
@@ -0,0 +1,30 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "SchedulingType" AS ENUM ('roundRobin', 'collective');
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "EventType" DROP CONSTRAINT "EventType_userId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "schedulingType" "SchedulingType",
|
||||
ADD COLUMN "teamId" INTEGER;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_user_eventtype" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "_user_eventtype_AB_unique" ON "_user_eventtype"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_user_eventtype_B_index" ON "_user_eventtype"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventType" ADD FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_user_eventtype" ADD FOREIGN KEY ("A") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_user_eventtype" ADD FOREIGN KEY ("B") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,15 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "DailyEventReference" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"dailyurl" TEXT NOT NULL DEFAULT E'dailycallurl',
|
||||
"dailytoken" TEXT NOT NULL DEFAULT E'dailytoken',
|
||||
"bookingId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DailyEventReference_bookingId_unique" ON "DailyEventReference"("bookingId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DailyEventReference" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "EventType.userId_slug_unique";
|
||||
@@ -0,0 +1,4 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "BookingReference" ADD COLUMN "meetingId" TEXT,
|
||||
ADD COLUMN "meetingPassword" TEXT,
|
||||
ADD COLUMN "meetingUrl" TEXT;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "twoFactorEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "twoFactorSecret" TEXT;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[userId,slug]` on the table `EventType` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventType.userId_slug_unique" ON "EventType"("userId", "slug");
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "locale" TEXT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "disableGuests" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,17 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "WebhookTriggerEvents" AS ENUM ('BOOKING_CREATED', 'BOOKING_RESCHEDULED', 'BOOKING_CANCELLED');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Webhook" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"subscriberUrl" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"active" BOOLEAN NOT NULL DEFAULT true,
|
||||
"eventTriggers" "WebhookTriggerEvents"[],
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Webhook.id_unique" ON "Webhook"("id");
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `periodType` on table `EventType` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `email` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `weekStart` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `completedOnboarding` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ALTER COLUMN "periodType" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ALTER COLUMN "email" SET NOT NULL,
|
||||
ALTER COLUMN "weekStart" SET NOT NULL,
|
||||
ALTER COLUMN "completedOnboarding" SET NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1 @@
|
||||
UPDATE "Booking" SET "status" = 'rejected' WHERE "rejected" = TRUE;
|
||||
@@ -0,0 +1,14 @@
|
||||
-- This is an empty migration.
|
||||
|
||||
ALTER TABLE "Availability" RENAME COLUMN "startTime" to "old_startTime";
|
||||
ALTER TABLE "Availability" RENAME COLUMN "endTime" to "old_endTime";
|
||||
ALTER TABLE "Availability" ADD COLUMN "startTime" TIME;
|
||||
ALTER TABLE "Availability" ADD COLUMN "endTime" TIME;
|
||||
|
||||
UPDATE "Availability" SET "startTime" = CAST(CONCAT(CAST(("old_startTime" / 60) AS text), ':00') AS time);
|
||||
UPDATE "Availability" SET "endTime" = CAST(CONCAT(CAST(("old_endTime" / 60) AS text), ':00') AS time);
|
||||
|
||||
ALTER TABLE "Availability" DROP COLUMN "old_startTime";
|
||||
ALTER TABLE "Availability" DROP COLUMN "old_endTime";
|
||||
ALTER TABLE "Availability" ALTER COLUMN "startTime" SET NOT NULL;
|
||||
ALTER TABLE "Availability" ALTER COLUMN "endTime" SET NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "position" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "brandColor" TEXT NOT NULL DEFAULT E'#292929';
|
||||
UPDATE "users" SET "brandColor" = '#292929';
|
||||
@@ -0,0 +1,6 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "IdentityProvider" AS ENUM ('CAL', 'GOOGLE');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "identityProvider" "IdentityProvider" NOT NULL DEFAULT E'CAL',
|
||||
ADD COLUMN "identityProviderId" TEXT;
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The `periodType` column on the `EventType` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PeriodType" AS ENUM ('unlimited', 'rolling', 'range');
|
||||
|
||||
-- AlterTable
|
||||
|
||||
ALTER TABLE "EventType" RENAME COLUMN "periodType" to "old_periodType";
|
||||
ALTER TABLE "EventType" ADD COLUMN "periodType" "PeriodType" NOT NULL DEFAULT E'unlimited';
|
||||
|
||||
UPDATE "EventType" SET "periodType" = "old_periodType"::"PeriodType";
|
||||
ALTER TABLE "EventType" DROP COLUMN "old_periodType";
|
||||
@@ -0,0 +1,2 @@
|
||||
-- add the new value to the existing type
|
||||
ALTER TYPE "IdentityProvider" ADD VALUE 'SAML';
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
insert into "Availability" ("userId", "startTime", "endTime", "days")
|
||||
select
|
||||
id as "userId",
|
||||
CAST(CONCAT(CAST(("startTime") AS text), ' minute')::interval AS time) as "startTime",
|
||||
CAST(CONCAT(CAST(("endTime") AS text), ' minute')::interval AS time) as "endTime",
|
||||
ARRAY [0,1,2,3,4,5,6]
|
||||
from
|
||||
(
|
||||
select
|
||||
users.id,
|
||||
users."startTime",
|
||||
users."endTime",
|
||||
users."timeZone",
|
||||
count("Availability".id) as availability_count
|
||||
from users
|
||||
left join "Availability" on "Availability"."userId" = users.id
|
||||
group by users.id
|
||||
) usersWithAvailabilityNumber
|
||||
where availability_count < 1
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Webhook" ADD COLUMN "payloadTemplate" TEXT;
|
||||
@@ -0,0 +1,29 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "DestinationCalendar" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"integration" TEXT NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"bookingId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.userId_unique" ON "DestinationCalendar"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.bookingId_unique" ON "DestinationCalendar"("bookingId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.eventTypeId_unique" ON "DestinationCalendar"("eventTypeId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "MembershipRole" ADD VALUE 'ADMIN';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "invitedTo" INTEGER;
|
||||
@@ -0,0 +1,74 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" DROP CONSTRAINT "EventTypeCustomInput_eventTypeId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Payment" DROP CONSTRAINT "Payment_bookingId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "SelectedCalendar" DROP CONSTRAINT "SelectedCalendar_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Webhook" DROP CONSTRAINT "Webhook_userId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD CONSTRAINT "SelectedCalendar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" ADD CONSTRAINT "EventTypeCustomInput_eventTypeId_fkey" FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Booking.uid_unique" RENAME TO "Booking_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.bookingId_unique" RENAME TO "DestinationCalendar_bookingId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.eventTypeId_unique" RENAME TO "DestinationCalendar_eventTypeId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.userId_unique" RENAME TO "DestinationCalendar_userId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "EventType.userId_slug_unique" RENAME TO "EventType_userId_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.externalId_unique" RENAME TO "Payment_externalId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.uid_unique" RENAME TO "Payment_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Team.slug_unique" RENAME TO "Team_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest.identifier_token_unique" RENAME TO "VerificationRequest_identifier_token_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest.token_unique" RENAME TO "VerificationRequest_token_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Webhook.id_unique" RENAME TO "Webhook_id_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.email_unique" RENAME TO "users_email_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.username_unique" RENAME TO "users_username_key";
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "slotInterval" INTEGER;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- UpdateTable
|
||||
UPDATE users SET email=LOWER(email);
|
||||
@@ -0,0 +1,38 @@
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Booking_uid_key" RENAME TO "Booking.uid_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_bookingId_key" RENAME TO "DestinationCalendar.bookingId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_eventTypeId_key" RENAME TO "DestinationCalendar.eventTypeId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_userId_key" RENAME TO "DestinationCalendar.userId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "EventType_userId_slug_key" RENAME TO "EventType.userId_slug_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment_externalId_key" RENAME TO "Payment.externalId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment_uid_key" RENAME TO "Payment.uid_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Team_slug_key" RENAME TO "Team.slug_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest_identifier_token_key" RENAME TO "VerificationRequest.identifier_token_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest_token_key" RENAME TO "VerificationRequest.token_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Webhook_id_key" RENAME TO "Webhook.id_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users_email_key" RENAME TO "users.email_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users_username_key" RENAME TO "users.username_unique";
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "scAddress" TEXT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "metadata" JSONB;
|
||||
@@ -0,0 +1,35 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Availability" DROP CONSTRAINT "Availability_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Credential" DROP CONSTRAINT "Credential_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Schedule" DROP CONSTRAINT "Schedule_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "SelectedCalendar" DROP CONSTRAINT "SelectedCalendar_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Webhook" DROP CONSTRAINT "Webhook_userId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD CONSTRAINT "Schedule_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD CONSTRAINT "Availability_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD CONSTRAINT "SelectedCalendar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "away" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" DROP COLUMN "scAddress",
|
||||
ADD COLUMN "smartContractAddress" TEXT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ALTER COLUMN "plan" SET DEFAULT E'TRIAL';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "cancellationReason" TEXT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Attendee" ADD COLUMN "locale" TEXT DEFAULT E'en';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "EventType" ADD COLUMN "metadata" JSONB;
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `smartContractAddress` on the `EventType` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" DROP COLUMN IF EXISTS "smartContractAddress";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "verified" BOOLEAN DEFAULT false;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "rejectionReason" TEXT;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Webhook" ADD COLUMN "eventTypeId" INTEGER,
|
||||
ALTER COLUMN "userId" DROP NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_eventTypeId_fkey" FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "timeFormat" INTEGER DEFAULT 12;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "afterEventBuffer" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN "beforeEventBuffer" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "darkBrandColor" TEXT NOT NULL DEFAULT E'#fafafa';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "trialEndsAt" TIMESTAMP(3);
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `label` on the `Availability` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `freeBusyTimes` on the `Schedule` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `title` on the `Schedule` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[eventTypeId]` on the table `Schedule` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `name` to the `Schedule` table without a default value. This is not possible if the table is not empty.
|
||||
- Made the column `userId` on table `Schedule` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Availability" DROP COLUMN "label",
|
||||
ADD COLUMN "scheduleId" INTEGER;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Schedule" DROP COLUMN "freeBusyTimes",
|
||||
DROP COLUMN "title",
|
||||
ADD COLUMN "name" TEXT NOT NULL,
|
||||
ADD COLUMN "timeZone" TEXT,
|
||||
ALTER COLUMN "userId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "defaultScheduleId" INTEGER;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Schedule_eventTypeId_key" ON "Schedule"("eventTypeId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD CONSTRAINT "Availability_scheduleId_fkey" FOREIGN KEY ("scheduleId") REFERENCES "Schedule"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,35 @@
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Booking.uid_unique" RENAME TO "Booking_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DailyEventReference_bookingId_unique" RENAME TO "DailyEventReference_bookingId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.bookingId_unique" RENAME TO "DestinationCalendar_bookingId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.eventTypeId_unique" RENAME TO "DestinationCalendar_eventTypeId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.userId_unique" RENAME TO "DestinationCalendar_userId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "EventType.userId_slug_unique" RENAME TO "EventType_userId_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.externalId_unique" RENAME TO "Payment_externalId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.uid_unique" RENAME TO "Payment_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Team.slug_unique" RENAME TO "Team_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Webhook.id_unique" RENAME TO "Webhook_id_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.email_unique" RENAME TO "users_email_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.username_unique" RENAME TO "users_username_key";
|
||||
@@ -0,0 +1,10 @@
|
||||
ALTER TABLE IF EXISTS "VerificationRequest" RENAME TO "VerificationToken";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX IF EXISTS "VerificationRequest_pkey" RENAME TO "VerificationToken_pkey";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX IF EXISTS "VerificationRequest_token_key" RENAME TO "VerificationToken_token_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX IF EXISTS "VerificationRequest_identifier_token_key" RENAME TO "VerificationToken_identifier_token_key";
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "fromReschedule" TEXT,
|
||||
ADD COLUMN "rescheduled" BOOLEAN;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "hideCalendarNotes" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "BookingReference" ADD COLUMN "deleted" BOOLEAN;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "dynamicEventSlugRef" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "dynamicGroupSlugRef" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "allowDynamicBooking" BOOLEAN DEFAULT true;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "successRedirectUrl" TEXT;
|
||||
@@ -0,0 +1,21 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "UserPermissionRole" AS ENUM ('USER', 'ADMIN');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "role" "UserPermissionRole" NOT NULL DEFAULT E'USER';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Impersonations" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"impersonatedUserId" INTEGER NOT NULL,
|
||||
"impersonatedById" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Impersonations_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Impersonations" ADD CONSTRAINT "Impersonations_impersonatedUserId_fkey" FOREIGN KEY ("impersonatedUserId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Impersonations" ADD CONSTRAINT "Impersonations_impersonatedById_fkey" FOREIGN KEY ("impersonatedById") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[teamId,slug]` on the table `EventType` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventType_teamId_slug_key" ON "EventType"("teamId", "slug");
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Payment" DROP CONSTRAINT "Payment_bookingId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,21 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ApiKey" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"note" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"expiresAt" TIMESTAMP(3),
|
||||
"lastUsedAt" TIMESTAMP(3),
|
||||
"hashedKey" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ApiKey_id_key" ON "ApiKey"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ApiKey_hashedKey_key" ON "ApiKey"("hashedKey");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "seatsPerTimeSlot" INTEGER;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "BookingReference" DROP CONSTRAINT "BookingReference_bookingId_fkey";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "HashedLink" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"link" TEXT NOT NULL,
|
||||
"eventTypeId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "HashedLink_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "HashedLink_link_key" ON "HashedLink"("link");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "HashedLink_eventTypeId_key" ON "HashedLink"("eventTypeId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BookingReference" ADD CONSTRAINT "BookingReference_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "HashedLink" ADD CONSTRAINT "HashedLink_eventTypeId_fkey" FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "BookingReference" DROP CONSTRAINT "BookingReference_bookingId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BookingReference" ADD CONSTRAINT "BookingReference_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user