fix(backend): the tests did dumb stuff like reusing ids

This commit is contained in:
Nicholas Tindle
2025-02-11 21:09:51 -06:00
parent 85f8f4136f
commit ddd2b9de15
3 changed files with 4 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ async def get_or_create_user(user_data: dict) -> User:
raise HTTPException(status_code=401, detail="Email not found in token")
user = await prisma.user.find_unique(
where={"id": user_id}, include={"UserNotificationPreference": True}
where={"id": user_id}
)
if not user:
user = await prisma.user.create(
@@ -39,7 +39,7 @@ async def get_or_create_user(user_data: dict) -> User:
"UserNotificationPreference": {"create": {"userId": user_id}},
}
)
if not user.UserNotificationPreference:
if not user.userNotificationPreferenceId:
user.UserNotificationPreference = (
await prisma.usernotificationpreference.create(data={"userId": user_id})
)

View File

@@ -62,7 +62,7 @@ CREATE UNIQUE INDEX "UserNotificationPreference_userId_key" ON "UserNotification
CREATE UNIQUE INDEX "User_userNotificationPreferenceId_key" ON "User"("userNotificationPreferenceId");
-- AddForeignKey
ALTER TABLE "User" ADD CONSTRAINT "User_userNotificationPreferenceId_fkey" FOREIGN KEY ("userNotificationPreferenceId") REFERENCES "UserNotificationPreference"("id") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "User" ADD CONSTRAINT "User_userNotificationPreferenceId_fkey" FOREIGN KEY ("userNotificationPreferenceId") REFERENCES "UserNotificationPreference"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "NotificationEvent" ADD CONSTRAINT "NotificationEvent_userNotificationBatchId_fkey" FOREIGN KEY ("userNotificationBatchId") REFERENCES "UserNotificationBatch"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -42,7 +42,7 @@ model User {
APIKeys APIKey[]
IntegrationWebhooks IntegrationWebhook[]
UserNotificationBatch UserNotificationBatch[]
UserNotificationPreference UserNotificationPreference? @relation(fields: [userNotificationPreferenceId], references: [id])
UserNotificationPreference UserNotificationPreference? @relation(fields: [userNotificationPreferenceId], references: [id], onDelete: Cascade)
@@index([id])
@@index([email])