Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/rename Subscription to subscriptions in user database schema (#4575)

Thomas Kaul3091c3f08093
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 038734f4bb..4674e0bec8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Made the historical market data editor expandable in the admin control panel
+- Renamed `Subscription` to `subscriptions` in the `User` database schema
- Parallelized the requests in the get quotes functionality of the _Financial Modeling Prep_ service
- Migrated the lookup functionality by `isin` of the _Financial Modeling Prep_ service to its stable API version
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index ccbec46f94..4cd4abcdb3 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -645,7 +645,7 @@ export class AdminService {
Order: {
where: {
User: {
- Subscription: {
+ subscriptions: {
some: {
expiresAt: {
gt: new Date()
@@ -806,7 +806,7 @@ export class AdminService {
createdAt: true,
id: true,
role: true,
- Subscription: {
+ subscriptions: {
orderBy: {
expiresAt: 'desc'
},
@@ -821,7 +821,7 @@ export class AdminService {
});
return usersWithAnalytics.map(
- ({ _count, Analytics, createdAt, id, role, Subscription }) => {
+ ({ _count, Analytics, createdAt, id, role, subscriptions }) => {
const daysSinceRegistration =
differenceInDays(new Date(), createdAt) + 1;
const engagement = Analytics
@@ -830,8 +830,8 @@ export class AdminService {
const subscription =
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') &&
- Subscription?.length > 0
- ? Subscription[0]
+ subscriptions?.length > 0
+ ? subscriptions[0]
: undefined;
return {
diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts
index 31d8786dfa..ebdf09ba5e 100644
--- a/apps/api/src/app/user/user.service.ts
+++ b/apps/api/src/app/user/user.service.ts
@@ -189,7 +189,7 @@ export class UserService {
provider,
role,
Settings,
- Subscription,
+ subscriptions,
thirdPartyId,
updatedAt
} = await this.prismaService.user.findUnique({
@@ -200,7 +200,7 @@ export class UserService {
},
Analytics: true,
Settings: true,
- Subscription: true
+ subscriptions: true
},
where: userWhereUniqueInput
});
@@ -340,8 +340,8 @@ export class UserService {
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
user.subscription = await this.subscriptionService.getSubscription({
- createdAt: user.createdAt,
- subscriptions: Subscription
+ subscriptions,
+ createdAt: user.createdAt
});
if (user.subscription?.type === 'Basic') {
diff --git a/apps/api/src/services/symbol-profile/symbol-profile.service.ts b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
index e934a63247..a24101e800 100644
--- a/apps/api/src/services/symbol-profile/symbol-profile.service.ts
+++ b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
@@ -55,14 +55,14 @@ export class SymbolProfileService {
? {
some: {
User: {
- Subscription: { some: { expiresAt: { gt: new Date() } } }
+ subscriptions: { some: { expiresAt: { gt: new Date() } } }
}
}
}
: {
every: {
User: {
- Subscription: { none: { expiresAt: { gt: new Date() } } }
+ subscriptions: { none: { expiresAt: { gt: new Date() } } }
}
}
}
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 637819fd8d..b649b38b69 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -250,6 +250,7 @@ model User {
id String @id @default(uuid())
provider Provider @default(ANONYMOUS)
role Role @default(USER)
+ subscriptions Subscription[]
thirdPartyId String?
updatedAt DateTime @updatedAt
watchlist SymbolProfile[] @relation("UserWatchlist")
@@ -261,7 +262,6 @@ model User {
AuthDevice AuthDevice[]
Order Order[]
Settings Settings?
- Subscription Subscription[]
SymbolProfile SymbolProfile[]
Tag Tag[]