From 73c0843d51915776c898de1a8e0be4d99135f6d3 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:23:58 +0100 Subject: [PATCH] Feature/add permissions to access model (#2833) * Add permissions to Access model * Update changelog --- CHANGELOG.md | 6 +++ .../migration.sql | 5 ++ prisma/schema.prisma | 46 +++++++++++-------- 3 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 prisma/migrations/20240106131428_added_permissions_to_access/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 387573f4f..748478d82 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 `permissions` to the `Access` model + ## 2.44.0 - 2024-01-24 ### Fixed diff --git a/prisma/migrations/20240106131428_added_permissions_to_access/migration.sql b/prisma/migrations/20240106131428_added_permissions_to_access/migration.sql new file mode 100644 index 000000000..75fb777d4 --- /dev/null +++ b/prisma/migrations/20240106131428_added_permissions_to_access/migration.sql @@ -0,0 +1,5 @@ +-- CreateEnum +CREATE TYPE "AccessPermission" AS ENUM ('READ', 'READ_RESTRICTED'); + +-- AlterTable +ALTER TABLE "Access" ADD COLUMN "permissions" "AccessPermission"[] DEFAULT ARRAY['READ_RESTRICTED']::"AccessPermission"[]; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e02b30e08..a5a57d8c0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -11,31 +11,32 @@ datasource db { model Access { alias String? - createdAt DateTime @default(now()) + createdAt DateTime @default(now()) granteeUserId String? - id String @id @default(uuid()) - updatedAt DateTime @updatedAt + id String @id @default(uuid()) + permissions AccessPermission[] @default([READ_RESTRICTED]) + updatedAt DateTime @updatedAt userId String - GranteeUser User? @relation("accessGet", fields: [granteeUserId], references: [id]) - User User @relation("accessGive", fields: [userId], references: [id]) + GranteeUser User? @relation("accessGet", fields: [granteeUserId], references: [id]) + User User @relation("accessGive", fields: [userId], references: [id]) } model Account { - balance Float @default(0) - balances AccountBalance[] - comment String? - createdAt DateTime @default(now()) - currency String? - id String @default(uuid()) - isDefault Boolean @default(false) - isExcluded Boolean @default(false) - name String? - platformId String? - updatedAt DateTime @updatedAt - userId String - Platform Platform? @relation(fields: [platformId], references: [id]) - User User @relation(fields: [userId], references: [id]) - Order Order[] + balance Float @default(0) + balances AccountBalance[] + comment String? + createdAt DateTime @default(now()) + currency String? + id String @default(uuid()) + isDefault Boolean @default(false) + isExcluded Boolean @default(false) + name String? + platformId String? + updatedAt DateTime @updatedAt + userId String + Platform Platform? @relation(fields: [platformId], references: [id]) + User User @relation(fields: [userId], references: [id]) + Order Order[] @@id([id, userId]) } @@ -196,6 +197,11 @@ model User { Subscription Subscription[] } +enum AccessPermission { + READ + READ_RESTRICTED +} + enum AssetClass { CASH COMMODITY