Skip to content

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

Feature/setup api keys for Ghostfolio data provider (#4088)

Thomas Kaul9461b32a3950
diff --git a/prisma/migrations/20241130164335_added_api_keys_to_user copy/migration.sql b/prisma/migrations/20241130164335_added_api_keys_to_user copy/migration.sql
new file mode 100644
index 0000000000..c538fd11b1
--- /dev/null
+++ b/prisma/migrations/20241130164335_added_api_keys_to_user copy/migration.sql
@@ -0,0 +1,19 @@
+-- CreateTable
+CREATE TABLE "ApiKey" (
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "hashedKey" TEXT NOT NULL,
+ "id" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "userId" TEXT NOT NULL,
+
+ CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE INDEX "ApiKey_hashedKey_idx" ON "ApiKey"("hashedKey");
+
+-- CreateIndex
+CREATE INDEX "ApiKey_userId_idx" ON "ApiKey"("userId");
+
+-- AddForeignKey
+ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 5fe4ce7c3e..e2587acf77 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -77,6 +77,18 @@ model Analytics {
@@index([updatedAt])
}
+model ApiKey {
+ createdAt DateTime @default(now())
+ hashedKey String
+ id String @id @default(uuid())
+ updatedAt DateTime @updatedAt
+ userId String
+ user User @relation(fields: [userId], onDelete: Cascade, references: [id])
+
+ @@index([hashedKey])
+ @@index([userId])
+}
+
model AuthDevice {
createdAt DateTime @default(now())
credentialId Bytes
@@ -238,6 +250,7 @@ model User {
AccessGive Access[] @relation("accessGive")
Account Account[]
Analytics Analytics?
+ ApiKey ApiKey[]
AuthDevice AuthDevice[]
Order Order[]
Settings Settings?