From 894398b2a7f495dcbd8fe66e36b5416b0a683b14 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 18 Apr 2025 14:40:41 +0200 Subject: [PATCH] Add watchlist --- .../migration.sql | 16 ++++++++++++++++ prisma/migrations/migration_lock.toml | 2 +- prisma/schema.prisma | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20250418123137_added_watchlist_to_user/migration.sql 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 000000000..25fd35041 --- /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 648c57fd5..044d57cdb 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 29c98788f..637819fd8 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[]