Feature/setup cascading on delete for various relations in database schema (#3445)

* Setup cascading on delete

* Update changelog
pull/3447/head
Thomas Kaul 4 months ago committed by GitHub
parent c009f8c12f
commit 69d85eadfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,11 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added the data provider information to the asset profile details dialog of the admin control - 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
- Fixed an issue with the initial annual interest rate in the _FIRE_ calculator - Fixed an issue with the initial annual interest rate in the _FIRE_ calculator
- Fixed the state handling in the currency selector - 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-30 ## 2.83.0 - 2024-05-30

@ -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;

@ -17,8 +17,8 @@ model Access {
permissions AccessPermission[] @default([READ_RESTRICTED]) permissions AccessPermission[] @default([READ_RESTRICTED])
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String userId String
GranteeUser User? @relation("accessGet", fields: [granteeUserId], references: [id]) GranteeUser User? @relation("accessGet", fields: [granteeUserId], onDelete: Cascade, references: [id])
User User @relation("accessGive", fields: [userId], references: [id]) User User @relation("accessGive", fields: [userId], onDelete: Cascade, references: [id])
@@index([alias]) @@index([alias])
@@index([granteeUserId]) @@index([granteeUserId])
@ -38,7 +38,7 @@ model Account {
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String userId String
Platform Platform? @relation(fields: [platformId], references: [id]) Platform Platform? @relation(fields: [platformId], references: [id])
User User @relation(fields: [userId], references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
Order Order[] Order Order[]
@@id([id, userId]) @@id([id, userId])
@ -69,7 +69,7 @@ model Analytics {
country String? country String?
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String @id userId String @id
User User @relation(fields: [userId], references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
@@index([updatedAt]) @@index([updatedAt])
} }
@ -82,7 +82,7 @@ model AuthDevice {
id String @id @default(uuid()) id String @id @default(uuid())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String userId String
User User @relation(fields: [userId], references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
@@index([userId]) @@index([userId])
} }
@ -123,7 +123,7 @@ model Order {
userId String userId String
Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId]) Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id]) 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[] tags Tag[]
@@index([accountId]) @@index([accountId])
@ -150,7 +150,7 @@ model Settings {
settings Json? settings Json?
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String @id userId String @id
User User @relation(fields: [userId], references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
} }
model SymbolProfile { model SymbolProfile {
@ -194,7 +194,7 @@ model SymbolProfileOverrides {
url String? url String?
symbolProfileId String @id symbolProfileId String @id
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id]) SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], onDelete: Cascade, references: [id])
} }
model Subscription { model Subscription {
@ -204,7 +204,7 @@ model Subscription {
price Float? price Float?
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String userId String
User User @relation(fields: [userId], references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
@@index([userId]) @@index([userId])
} }

Loading…
Cancel
Save