Skip to content

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

Feature/add watchlist to user database schema (#4560)

Thomas Kaul1b45ce8619d6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7bd31d5e7d..0874d91d99 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Added
+
+- Added `watchlist` to the `User` database schema as a preparation for watching assets
+
## 2.153.0 - 2025-04-18
### Changed
diff --git a/prisma/migrations/20250418123137_added_watchlist_to_user/migration.sql b/prisma/migrations/20250418123137_added_watchlist_to_user/migration.sql
new file mode 100644
index 0000000000..25fd350412
--- /dev/null
+++ b/prisma/migrations/20250418123137_added_watchlist_to_user/migration.sql
@@ -0,0 +1,16 @@
+-- CreateTable
+CREATE TABLE "_UserWatchlist" (
+ "A" TEXT NOT NULL,
+ "B" TEXT NOT NULL,
+
+ CONSTRAINT "_UserWatchlist_AB_pkey" PRIMARY KEY ("A","B")
+);
+
+-- CreateIndex
+CREATE INDEX "_UserWatchlist_B_index" ON "_UserWatchlist"("B");
+
+-- AddForeignKey
+ALTER TABLE "_UserWatchlist" ADD CONSTRAINT "_UserWatchlist_A_fkey" FOREIGN KEY ("A") REFERENCES "SymbolProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "_UserWatchlist" ADD CONSTRAINT "_UserWatchlist_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml
index 648c57fd59..044d57cdb0 100644
--- a/prisma/migrations/migration_lock.toml
+++ b/prisma/migrations/migration_lock.toml
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
-provider = "postgresql"
\ No newline at end of file
+provider = "postgresql"
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 29c98788fa..637819fd8d 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -191,6 +191,7 @@ model SymbolProfile {
symbolMapping Json?
url String?
userId String?
+ watchedBy User[] @relation("UserWatchlist")
Order Order[]
SymbolProfileOverrides SymbolProfileOverrides?
User User? @relation(fields: [userId], onDelete: Cascade, references: [id])
@@ -251,6 +252,7 @@ model User {
role Role @default(USER)
thirdPartyId String?
updatedAt DateTime @updatedAt
+ watchlist SymbolProfile[] @relation("UserWatchlist")
Access Access[] @relation("accessGet")
AccessGive Access[] @relation("accessGive")
Account Account[]