mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend): the tests did dumb stuff like reusing ids
This commit is contained in:
@@ -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})
|
||||
)
|
||||
|
||||
@@ -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;
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user