Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/setup cascading on delete for various relations in database schema (#3445)
Thomas Kaul69d85eadfdf6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 274071d21e..9a09ee3dd1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,11 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added- Added the data provider information to the asset profile details dialog of the admin control+- Added the cascading on delete for various relations in the database schema### Fixed- Fixed an issue with the initial annual interest rate in the _FIRE_ calculator- Fixed the state handling in the currency selector+- Fixed the deletion of an asset profile with symbol profile overrides in the asset profile details dialog of the admin control## 2.83.0 - 2024-05-30diff --git a/prisma/migrations/20240601083002_added_cascade_on_delete_for_various_relations/migration.sql b/prisma/migrations/20240601083002_added_cascade_on_delete_for_various_relations/migration.sqlnew file mode 100644index 0000000000..46b08f6064--- /dev/null+++ b/prisma/migrations/20240601083002_added_cascade_on_delete_for_various_relations/migration.sql@@ -0,0 +1,53 @@+-- DropForeignKey+ALTER TABLE "Access" DROP CONSTRAINT "Access_granteeUserId_fkey";++-- DropForeignKey+ALTER TABLE "Access" DROP CONSTRAINT "Access_userId_fkey";++-- DropForeignKey+ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey";++-- DropForeignKey+ALTER TABLE "Analytics" DROP CONSTRAINT "Analytics_userId_fkey";++-- DropForeignKey+ALTER TABLE "AuthDevice" DROP CONSTRAINT "AuthDevice_userId_fkey";++-- DropForeignKey+ALTER TABLE "Order" DROP CONSTRAINT "Order_userId_fkey";++-- DropForeignKey+ALTER TABLE "Settings" DROP CONSTRAINT "Settings_userId_fkey";++-- DropForeignKey+ALTER TABLE "Subscription" DROP CONSTRAINT "Subscription_userId_fkey";++-- DropForeignKey+ALTER TABLE "SymbolProfileOverrides" DROP CONSTRAINT "SymbolProfileOverrides_symbolProfileId_fkey";++-- AddForeignKey+ALTER TABLE "Access" ADD CONSTRAINT "Access_granteeUserId_fkey" FOREIGN KEY ("granteeUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Access" ADD CONSTRAINT "Access_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Analytics" ADD CONSTRAINT "Analytics_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AuthDevice" ADD CONSTRAINT "AuthDevice_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Order" ADD CONSTRAINT "Order_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Settings" ADD CONSTRAINT "Settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "SymbolProfileOverrides" ADD CONSTRAINT "SymbolProfileOverrides_symbolProfileId_fkey" FOREIGN KEY ("symbolProfileId") REFERENCES "SymbolProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex 43052de118..6293cfc185 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -17,8 +17,8 @@ model Access {permissions AccessPermission[] @default([READ_RESTRICTED])updatedAt DateTime @updatedAtuserId String- GranteeUser User? @relation("accessGet", fields: [granteeUserId], references: [id])- User User @relation("accessGive", fields: [userId], references: [id])+ GranteeUser User? @relation("accessGet", fields: [granteeUserId], onDelete: Cascade, references: [id])+ User User @relation("accessGive", fields: [userId], onDelete: Cascade, references: [id])@@index([alias])@@index([granteeUserId])@@ -38,7 +38,7 @@ model Account {updatedAt DateTime @updatedAtuserId StringPlatform Platform? @relation(fields: [platformId], references: [id])- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])Order Order[]@@id([id, userId])@@ -69,7 +69,7 @@ model Analytics {country String?updatedAt DateTime @updatedAtuserId String @id- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])@@index([updatedAt])}@@ -82,7 +82,7 @@ model AuthDevice {id String @id @default(uuid())updatedAt DateTime @updatedAtuserId String- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])@@index([userId])}@@ -123,7 +123,7 @@ model Order {userId StringAccount Account? @relation(fields: [accountId, accountUserId], references: [id, userId])SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id])- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])tags Tag[]@@index([accountId])@@ -150,7 +150,7 @@ model Settings {settings Json?updatedAt DateTime @updatedAtuserId String @id- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])}model SymbolProfile {@@ -194,7 +194,7 @@ model SymbolProfileOverrides {url String?symbolProfileId String @idupdatedAt DateTime @updatedAt- SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id])+ SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], onDelete: Cascade, references: [id])}model Subscription {@@ -204,7 +204,7 @@ model Subscription {price Float?updatedAt DateTime @updatedAtuserId String- User User @relation(fields: [userId], references: [id])+ User User @relation(fields: [userId], onDelete: Cascade, references: [id])@@index([userId])}