Squashing

This commit is contained in:
Luke Vella 2024-12-19 17:09:06 +00:00
parent a0b0098e5c
commit dac3766542
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
4 changed files with 52 additions and 69 deletions

View file

@ -1,21 +0,0 @@
/*
Warnings:
- Made the column `user_id` on table `comments` required. This step will fail if there are existing NULL values in that column.
- Made the column `user_id` on table `participants` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "comments" DROP CONSTRAINT "comments_user_id_fkey";
-- AlterTable
ALTER TABLE "comments" ALTER COLUMN "user_id" SET NOT NULL;
-- AlterTable
ALTER TABLE "participants" ALTER COLUMN "user_id" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "participants" ADD CONSTRAINT "participants_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -0,0 +1,39 @@
/*
Warnings:
- Made the column `user_id` on table `comments` required. This step will fail if there are existing NULL values in that column.
- Made the column `user_id` on table `participants` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "comments" DROP CONSTRAINT "comments_user_id_fkey";
-- DropForeignKey
ALTER TABLE "events" DROP CONSTRAINT "events_user_id_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_subscription_id_fkey";
-- DropForeignKey
ALTER TABLE "watchers" DROP CONSTRAINT "watchers_user_id_fkey";
-- AlterTable
ALTER TABLE "comments" ALTER COLUMN "user_id" SET NOT NULL;
-- AlterTable
ALTER TABLE "participants" ALTER COLUMN "user_id" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_subscription_id_fkey" FOREIGN KEY ("subscription_id") REFERENCES "subscriptions"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "events" ADD CONSTRAINT "events_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "watchers" ADD CONSTRAINT "watchers_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "participants" ADD CONSTRAINT "participants_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -40,7 +40,7 @@ model User {
id String @id @default(cuid())
name String?
email String? @unique() @db.Citext
emailVerified DateTime? @map("email_verified")
emailVerified DateTime? @map("email_verified")
isGuest Boolean @default(false) @map("is_guest")
image String?
timeZone String? @map("time_zone")
@ -52,11 +52,12 @@ model User {
customerId String? @map("customer_id")
subscriptionId String? @unique @map("subscription_id")
subscription Subscription? @relation(fields: [subscriptionId], references: [id], onDelete: Cascade)
comments Comment[]
polls Poll[]
watcher Watcher[]
events Event[]
subscription Subscription? @relation(fields: [subscriptionId], references: [id])
accounts Account[]
participants Participant[]
@ -155,13 +156,13 @@ model Poll {
model Event {
id String @id @default(cuid())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id])
optionId String @map("option_id")
title String
start DateTime @db.Timestamp(0)
duration Int @default(0) @map("duration_minutes")
createdAt DateTime @default(now()) @map("created_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
poll Poll?
@@map("events")
@ -170,11 +171,11 @@ model Event {
model Watcher {
id Int @id @default(autoincrement())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id])
pollId String @map("poll_id")
createdAt DateTime @default(now()) @map("created_at")
poll Poll @relation("PollToWatchers", fields: [pollId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
poll Poll @relation("PollToWatchers", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("watchers")
@ -205,9 +206,10 @@ model Option {
startTime DateTime @map("start_time") @db.Timestamp(0)
duration Int @default(0) @map("duration_minutes")
pollId String @map("poll_id")
poll Poll @relation("PollToOptions", fields: [pollId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @map("created_at")
poll Poll @relation("PollToOptions", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("options")
}
@ -248,7 +250,7 @@ model Comment {
updatedAt DateTime? @updatedAt @map("updated_at")
poll Poll @relation("PollToComments", fields: [pollId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("comments")