From e67ccea67364cac343e47f81adfd82912a3ef9cf Mon Sep 17 00:00:00 2001
From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com>
Date: Tue, 22 Apr 2025 19:38:03 +0200
Subject: [PATCH] Feature/rename User to user in subscription database schema
 (#4576)

* Rename User to user

* Update changelog
---
 CHANGELOG.md                                          | 4 ++++
 apps/api/src/app/subscription/subscription.service.ts | 2 +-
 prisma/schema.prisma                                  | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 221a6881..cbadcebc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Added the endpoints (`DELETE`, `GET` and `POST`) for the watchlist
 
+### Changed
+
+- Renamed `User` to `user` in the `Subscription` database schema
+
 ## 2.154.0 - 2025-04-21
 
 ### Added
diff --git a/apps/api/src/app/subscription/subscription.service.ts b/apps/api/src/app/subscription/subscription.service.ts
index f9533468..063c4060 100644
--- a/apps/api/src/app/subscription/subscription.service.ts
+++ b/apps/api/src/app/subscription/subscription.service.ts
@@ -122,7 +122,7 @@ export class SubscriptionService {
       data: {
         expiresAt,
         price,
-        User: {
+        user: {
           connect: {
             id: userId
           }
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index b649b38b..b88a5f9f 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -226,8 +226,8 @@ model Subscription {
   id        String   @id @default(uuid())
   price     Float?
   updatedAt DateTime @updatedAt
+  user      User     @relation(fields: [userId], onDelete: Cascade, references: [id])
   userId    String
-  User      User     @relation(fields: [userId], onDelete: Cascade, references: [id])
 
   @@index([userId])
 }