From 8ee7172ea07b91750f8a622282f21fea625f2fa8 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Tue, 27 Dec 2022 16:26:25 -0800 Subject: [PATCH] drop foreign keys, add missing indexes --- .../03_drop_foreign_keys/migration.sql | 17 +++++++++++++++++ db/postgresql/schema.prisma | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 db/postgresql/migrations/03_drop_foreign_keys/migration.sql diff --git a/db/postgresql/migrations/03_drop_foreign_keys/migration.sql b/db/postgresql/migrations/03_drop_foreign_keys/migration.sql new file mode 100644 index 00000000..1e71cede --- /dev/null +++ b/db/postgresql/migrations/03_drop_foreign_keys/migration.sql @@ -0,0 +1,17 @@ +-- DropForeignKey +ALTER TABLE "team_user" DROP CONSTRAINT "team_user_team_id_fkey"; + +-- DropForeignKey +ALTER TABLE "team_user" DROP CONSTRAINT "team_user_user_id_fkey"; + +-- DropForeignKey +ALTER TABLE "website" DROP CONSTRAINT "website_team_id_fkey"; + +-- DropForeignKey +ALTER TABLE "website" DROP CONSTRAINT "website_user_id_fkey"; + +-- CreateIndex +CREATE INDEX "website_team_id_idx" ON "website"("team_id"); + +-- CreateIndex +CREATE INDEX "website_user_id_idx" ON "website"("user_id"); diff --git a/db/postgresql/schema.prisma b/db/postgresql/schema.prisma index 5a084865..7e4e20d1 100644 --- a/db/postgresql/schema.prisma +++ b/db/postgresql/schema.prisma @@ -5,6 +5,7 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") + relationMode = "prisma" } model User { @@ -54,6 +55,8 @@ model Website { team Team? @relation(fields: [teamId], references: [id]) user User? @relation(fields: [userId], references: [id]) + @@index([teamId]) + @@index([userId]) @@index([createdAt]) @@index([shareId]) @@map("website")