Git Product home page Git Product logo

prisma-erd-generator's Introduction

Prisma Entity Relationship Diagram Generator

All Contributors

Prisma generator to create an ER Diagram every time you generate your prisma client.

Like this tool? @Skn0tt started this effort with his web app ER diagram generator

npm i -D prisma-erd-generator @mermaid-js/mermaid-cli
# or
yarn add -D prisma-erd-generator @mermaid-js/mermaid-cli

Add to your schema.prisma

generator erd {
  provider = "prisma-erd-generator"
}

Run the generator

npx prisma generate

Example ER Diagram

Versions

  • Prisma >= 4 use 1.x.x
  • Prisma <4 use 0.11.x

Options

Additional configuration

Output

Change output type and location

Usage

generator erd {
  provider = "prisma-erd-generator"
  output = "../ERD.svg"
}

Extensions

  • svg (default: ./prisma/ERD.svg)
  • png
  • pdf
  • md

Theme

Theme selection

Usage

generator erd {
  provider = "prisma-erd-generator"
  theme = "forest"
}

Options

  • default (default)
  • forest
  • dark
  • neutral

This option does not accept environment variables or other dynamic values. If you want to change the theme dynamically, you can use the theme option in the mermaidConfig option. See Mermaid Configuration for more information.

mmdcPath

In order for this generator to succeed you must have mmdc installed. This is the mermaid cli tool that is used to generate the ERD. By default the generator searches for an existing binary file at /node_modules/.bin. If it fails to find that binary it will run find ../.. -name mmdc to search through your folder for a mmdc binary. If you are using a different package manager or have a different location for your binary files, you can specify the path to the binary file.

generator erd {
  provider = "prisma-erd-generator"
  theme = "forest"
  mmdcPath = "node_modules/.bin"
}

Use with yarn 3+

Yarn 3+ doesn't create a node_modules/.bin directory for scripts when using the pnp or pnpm nodeLinkers (see yarn documentation here). It instead makes scripts available directly from the package.json file using yarn <script_name>, which means that there won't be an mmdc file created at all. This issue can be solved by creating your own shell script named mmdc inside your project's files that runs yarn mmdc (note: this shell script does not need to be added to your package.json file's scripts section - prisma-erd-generatr will access this script directly).

An example mmdc script:

#!/bin/bash

# $@ passes the parameters that this mmdc script was run with along to the mermaid cli
yarn mmdc $@

Make this mmdc script executable by using the command chmod +x mmdc, then set the mmdcPath option to point to the directory where the mmdc file you've just created is stored.

Disabled

You won't always need to generate a new ERD. For instance, when you are building your docker containers you often run prisma generate and if this generator is included, odds are you aren't relying on an updated ERD inside your docker container. It also adds additional space to the container because of dependencies such as puppeteer. There are two ways to disable this ERD generator.

  1. Via environment variable
DISABLE_ERD=true
  1. Via configuration
generator erd {
  provider = "prisma-erd-generator"
  disabled = true
}

Another option used is to remove the generator lines from your schema before installing dependencies and running the prisma generate command. I have used sed to remove the lines the generator is located on in my schema.prisma file to do so. Here is an example of the ERD generator being removed on lines 5-9 in a dockerfile.

# remove and replace unnecessary generators (erd generator)
# Deletes lines 5-9 from prisma/schema.prisma
RUN sed -i '5,9d' prisma/schema.prisma

Debugging

If you have issues with generating or outputting an ERD as expected, you may benefit from seeing output of the steps to making your ERD. Enable debugging by either adding the following environment variable

ERD_DEBUG=true

or adding in the debug configuration key set to true

generator erd {
  provider = "prisma-erd-generator"
  erdDebug = true
}

and re-running prisma generate. You should see a directory and files created labeling the steps to create an ER diagram under prisma/debug.

Please use these files as part of opening an issue if you run into problems.

Table only mode

Table mode only draws your models and skips the attributes and columns associated with your table. This feature is helpful for when you have lots of table columns and they are less helpful than seeing the tables and their relationships

generator erd {
  provider = "prisma-erd-generator"
  tableOnly = true
}

Ignore enums

If you enable this option, enum entities will be hidden. This is useful if you want to reduce the number of entities and focus on the tables and their columns and relationships.

generator erd {
  provider = "prisma-erd-generator"
  ignoreEnums = true
}

Include relation from field

By default this module skips relation fields in the result diagram. For example fields userId and productId will not be generated from this prisma schema.

model User {
  id            String         @id
  email         String
  favoriteProducts  FavoriteProducts[]
}


model Product {
  id              String        @id
  title           String
  inFavorites  FavoriteProducts[]
}

model FavoriteProducts {
  userId      String
  user        User    @relation(fields: [userId], references: [id])
  productId   String
  product     Product @relation(fields: [productId], references: [id])

  @@id([userId, productId])
}

It can be useful to show them when working with RDBMS. To show them use includeRelationFromFields = true

generator erd {
  provider = "prisma-erd-generator"
  includeRelationFromFields = true
}

Disable emoji output

The emoji output for primary keys (🗝️) and nullable fields () can be disabled, restoring the older values of PK and nullable, respectively.

generator erd {
  provider     = "prisma-erd-generator"
  disableEmoji = true
}

Mermaid configuration

Overriding the default mermaid configuration may be necessary to represent your schema in the best way possible. There is an example mermaid config here that you can use as a starting point. In the example JavaScript file, types are referenced to view all available options. You can also view them here. The most common use cases for needing to overwrite mermaid configuration is for theming and default sizing of the ERD.

generator erd {
  provider = "prisma-erd-generator"
  mermaidConfig = "mermaidConfig.json"
}

Puppeteer configuration

If you want to change the configuration of Puppeteer, create a Puppeteer config file (JSON) and pass the file path to the generator.

generator erd {
  provider = "prisma-erd-generator"
  puppeteerConfig = "../puppeteerConfig.json"
}

Issues

Because this package relies on mermaid js and puppeteer issues often are opened that relate to those libraries causing issues between different versions of Node.js and your operating system. As a fallback, if you are one of those people not able to generate an ERD using this generator, try running the generator to output a markdown file .md first. Trying to generate a markdown file doesn't run into puppeteer to represent the contents of a mermaid drawing in a browser and often will succeed. This will help get you a functioning ERD while troubleshooting why puppeteer is not working for your machine. Please open an issue if you have any problems or suggestions.

🔴 ARM64 Users 🔴

Puppeteer does not yet come shipped with a version of Chromium for arm64, so you will need to point to a Chromium executable on your system. More details on this issue can be found here.

MacOS Fix:

Install Chromium using Brew:

brew install --cask --no-quarantine chromium

You should now see the path to your installed Chromium.

which chromium

The generator will use this Chromium instead of the one provided by Puppeteer.

Other Operating Systems:

This can be fixed by either:

  • Setting the executablePath property in your puppeteer config file to the file path of the Chromium executable on your system.
  • Setting the following global variables on your system
    PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
    PUPPETEER_EXECUTABLE_PATH=path_to_your_chromium
    

Contributors ✨

Thanks goes to these wonderful people (emoji key):

John Fay
John Fay

🚧 💻 🤔 🐛
Jonas Strassel
Jonas Strassel

🐛 💻
Steve Gray
Steve Gray

💻 🤔
Jason Abbott
Jason Abbott

🐛 💻
Manuel Maute
Manuel Maute

🐛 💻
James Homer
James Homer

💻
Jan Piotrowski
Jan Piotrowski

🐛 💻 👀
Luke Evers
Luke Evers

💻
rikuyam
rikuyam

💻
Francis Manansala
Francis Manansala

🐛
Vitalii Yarmus
Vitalii Yarmus

💻
Petri Julkunen
Petri Julkunen

🐛
D-PONTARO
D-PONTARO

💻
Stephen Ramthun
Stephen Ramthun

📖
Tristan Chin
Tristan Chin

💻
Brandin Canfield
Brandin Canfield

💻
kota marusue
kota marusue

📖
Lucia
Lucia

🐛
Austin Ziegler
Austin Ziegler

💻
Janeene Beeforth
Janeene Beeforth

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

prisma-erd-generator's People

Contributors

allcontributors[bot] avatar balzafin avatar bcanfield avatar boredland avatar dawnmist avatar dependabot[bot] avatar dznbk avatar halostatue avatar heystevegray avatar janpio avatar jason-abbott avatar jsbrain avatar keonik avatar lucia-w avatar lukevers avatar maxijonson avatar mrsekut avatar ripry avatar stephenramthun avatar vitalii4as avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

prisma-erd-generator's Issues

Command failed when i try generator

Hi, i have this error when i try run npx prisma generate, I can run with the md extension but when I try to use png or svg this error occurs

image

Table only mode

Sometimes the ERD gets so big, that just having an overview of the tables and relations is enough. Would be great if the generator had a config option to enable that.

In Mermaid this is achievable by just not have any table definitions (with type -> name lists).

Why relationFromFields are deleted from the mermaid model

Hello, I'm trying to understand why some fields are removed during the generation of mermaid diagram. For example I have such a schema:

model User {
  id            String         @id
  email         String
  favoriteProducts  FavoriteProducts[]
}


model Product {
  id              String        @id
  title           String
  inFavorites  FavoriteProducts[]
}

model FavoriteProducts {
  userId      String
  user        User    @relation(fields: [userId], references: [id])
  productId   String
  product     Product @relation(fields: [productId], references: [id])

  @@id([userId, productId])
}

The generated mermaid diagram doesn't contain userId and productId. Is it possible to somehow show them?

erDiagram

  User {
    String id PK 
    String email  
    }
  

  Product {
    String id PK 
    String title  
    }
  

  FavoriteProducts {

    }
  
    FavoriteProducts o{--|| User : "user"
    FavoriteProducts o{--|| Product : "product"

Loading

I checked source code and they are filtered out in file src/generate.ts:178 - 182 Why it was done in such a way?

Thanks for your answer.

"Generating single mermaid chart"

Using the current version, I get the following output:

C:\Users\Jan\Documents\throwaway\3130>npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Generating single mermaid chart

✔ Generated Prisma Client (3.7.0 | library) to .\node_modules\@prisma\client in 11.15s 

✔ Generated Entity-relationship-diagram to .\prisma\ERD.svg in 8.82s
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
```

Might be that Generating single mermaid chart is some leftover debugging output.

"prisma-erd-generator": "^0.8.0"

Could not parse datamodel

Error: could not parse datamodel
at Object.exports.default [as onGenerate] (D:\My Projects\Nestjs\crud-test\node_modules\prisma-erd-generator\dist\generate.js:175:19)

"prisma-erd-generator": "^0.9.2",

Fails on Windows if more than a few models

This line

child_process.exec(`${engine} --datamodel=${modelB64} cli dmmf`);

throws

The command line is too long.

    at ChildProcess.exithandler (child_process.js:383:12)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)

I have about 30 models in a schema.prisma that's 480 lines — so not that big, really. I can copy out the command and run it directly from the Windows terminal without trouble, i.e.

> node_modules\prisma\query-engine-windows.exe --datamodel=[bunch of Base64] cli dmmf

so pretty sure it's just a node Windows limitation.

I am looking into whether there's a different way to process the file.

No output

Sadly for me (Arch Linux, nothing fancy), there is no output. For a test I did spin up a Github Workspaces instance with the latest commit. Running npm run dev-test here resulted in no new ERD.svg being generated.

Nullable or not on generated erd

Hi there,

thanks for this useful tool, just need to know can we see the required or can nullable at every field on ERD after generated?

I can't create svg with Docker (Debian)

What do you need to create in Debian or Ubuntu?

Docker Image:node:16
https://hub.docker.com/layers/node/library/node/16/images/sha256-1d35d3b639b639fb55d955d271c1da97d9e730c7dc0b9bae352a63c50b7c12c1?context=explore

package.json

{
  "name": "app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "ts-node-dev --respawn --debug --exit-child src/index.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@prisma/client": "^3.5.0",
    "@types/express": "^4.17.13",
    "@types/node": "^16.11.9",
    "express": "^4.17.1",
    "mermaid.cli": "^0.5.1",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.2"
  },
  "devDependencies": {
    "prisma": "^3.5.0",
    "prisma-erd-generator": "^0.6.1",
    "ts-node-dev": "^1.1.8"
  },
  "prisma": {
    "seed": "ts-node prisma/seed.ts"
  }
}

schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator erd {
  provider = "prisma-erd-generator"
  output   = "./ERD.svg"
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  age   Int?

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")

  profile Profile?
  posts   Post[]

  @@map("users")
}

model Profile {
  id       Int    @id @default(autoincrement())
  nickName String @map("nick_name")

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")

  userId Int  @unique
  user   User @relation(fields: [userId], references: [id])

  @@map("profile")
}

model Post {
  id    Int    @id @default(autoincrement())
  title String @map("title")
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")
  
  userId Int
  user   User @relation(fields: [userId], references: [id])

  @@map("posts")
}

No output?

I have a schema with a few tables, models omitted in the sample. Whenever I run npx prisma generate, the generator tells me that it has generated ./prisma/ERD.svg , but the file does not show up in ../prisma.

Debugger attached.
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (2.28.0) to ./node_modules/@prisma/client in 290ms

✔ Generated Entity relationship diagram to ./prisma/ERD.svg in 828ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

Im using

  "dependencies": {
    "@next-auth/prisma-adapter": "^0.5.3",
    "@prisma/client": "^2.28.0",
    ...
  },
  "devDependencies": {
    "prisma": "^2.28.0",
    "prisma-erd-generator": "^0.3.3"
  }

My schema looks like so, models omitted in the sample:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["orderByRelation"]
}

generator erd {
  provider = "prisma-erd-generator"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Heads up: Composite Types

We will soon release a new feature, that is relevant for ERD generation: Composite Types. They are pretty much like Models, but represent Embedded Documents for MongoDB for example:

This is what the underlying data looks like: https://docs.atlas.mongodb.com/sample-data/sample-airbnb/

And this the schema:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

datasource db {
  provider = "mongodb"
  url      = "mongodb+srv://us...godb.net/sample_airbnb"
}

type ListingsAndReviewsAddress {
  country         String
  country_code    String
  government_area String
  location        ListingsAndReviewsAddressLocation
  market          String
  street          String
  suburb          String
}

type ListingsAndReviewsAddressLocation {
  coordinates       Float[]
  is_location_exact Boolean
  type              String
}

type ListingsAndReviewsAvailability {
  availability_30  Int
  availability_365 Int
  availability_60  Int
  availability_90  Int
}

type ListingsAndReviewsHost {
  host_about                String
  host_has_profile_pic      Boolean
  host_id                   String
  host_identity_verified    Boolean
  host_is_superhost         Boolean
  host_listings_count       Int
  host_location             String
  host_name                 String
  host_neighbourhood        String
  host_picture_url          String
  host_response_rate        Int?
  host_response_time        String?
  host_thumbnail_url        String
  host_total_listings_count Int
  host_url                  String
  host_verifications        String[]
}

type ListingsAndReviewsImages {
  medium_url     String
  picture_url    String
  thumbnail_url  String
  xl_picture_url String
}

type ListingsAndReviewsReviewScores {
  review_scores_accuracy      Int?
  review_scores_checkin       Int?
  review_scores_cleanliness   Int?
  review_scores_communication Int?
  review_scores_location      Int?
  review_scores_rating        Int?
  review_scores_value         Int?
}

type ListingsAndReviewsReviews {
  id            String   @map("_id")
  comments      String?
  date          DateTime @db.Date
  listing_id    String
  reviewer_id   String
  reviewer_name String
}

model listingsAndReviews {
  id                    String                         @id @map("_id")
  access                String
  accommodates          Int
  address               ListingsAndReviewsAddress
  amenities             String[]
  availability          ListingsAndReviewsAvailability
  bathrooms             Decimal?
  bed_type              String
  bedrooms              Int?
  beds                  Int?
  calendar_last_scraped DateTime                       @db.Date
  cancellation_policy   String
  cleaning_fee          Decimal?
  description           String
  extra_people          Decimal
  first_review          DateTime?                      @db.Date
  guests_included       Decimal
  host                  ListingsAndReviewsHost
  house_rules           String
  images                ListingsAndReviewsImages
  interaction           String
  last_review           DateTime?                      @db.Date
  last_scraped          DateTime                       @db.Date
  listing_url           String
  maximum_nights        String
  minimum_nights        String
  monthly_price         Decimal?
  name                  String
  neighborhood_overview String
  notes                 String
  number_of_reviews     Int
  price                 Decimal
  property_type         String
  review_scores         ListingsAndReviewsReviewScores
  reviews               ListingsAndReviewsReviews[]
  reviews_per_month     Int?
  room_type             String
  security_deposit      Decimal?
  space                 String
  summary               String
  transit               String
  weekly_price          Decimal?

  @@index([property_type, room_type, beds], map: "property_type_1_room_type_1_beds_1")
  @@index([name], map: "name_1")
}

So we have one model, that then uses quite a few type in place where there could also be a Json field.

It probably makes sense to display these composite types as normal "tables" via "relations" - 1-1 or 1-n (lists) are possible. They don't have a primary key and can not include relations, and their usage is also not via @relation but more like a type.

Let me know if you have any questions.

"Maximum Text Size In Diagram Exceeded"

When creating a diagram for the following Prisma schema (via prisma/prisma#10856 (comment)) I get a "Maximum Text Size In Diagram Exceeded" instead of a real diagram:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

generator erd {
  provider = "prisma-erd-generator"
}

model AccountBalances {
  AccountBalanceID_PK String    @id
  AccountID_FK        String?
  Date                Float?
  Balance             Float?
  TotalMarketValue    Float?
  Accounts            Accounts? @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
}

model AccountDefaultsTags {
  AccountID_NN_FK String
  TagID_NN_FK     String
  Accounts        Accounts @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Tags            Tags     @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)

  @@id([AccountID_NN_FK, TagID_NN_FK])
}

model AccountGroups {
  AccountGroupID_PK                                     String                              @id
  ParentID_FK                                           String?
  Position                                              Int?
  WebsiteID_UK_FK                                       String?                             @unique(map: "sqlite_autoindex_AccountGroups_2")
  TypeNumber                                            Int?
  CurrencyCode                                          String?
  IncludeInBalances                                     Int?
  IncludeInSidebar                                      Int?
  IncludeInTransactions                                 Int?
  IncludeInLists                                        Int?
  IncludeInReports                                      Int?
  IncludePendingTransactions                            Int?
  Favorite                                              Int?
  Name                                                  String?
  ShortName                                             String?
  Info                                                  String?
  ColorString                                           String?
  AlternateColorString                                  String?
  TintColorString                                       String?
  AlternateTintColorString                              String?
  ImageData                                             Bytes?
  AlternateImageData                                    Bytes?
  SubtitleTypeNumber                                    Int?
  Subtitle                                              String?
  BalanceOptionTypeNumber                               Int?
  MinimumBalance                                        Float?
  MinimumBalanceAlertTypeNumber                         Int?
  MinimumBalanceForAlert                                Float?
  MaximumBalance                                        Float?
  MaximumBalanceAlertTypeNumber                         Int?
  MaximumBalanceForAlert                                Float?
  MiscValues                                            Bytes?
  AccountGroups                                         AccountGroups?                      @relation("AccountGroupsToAccountGroups_ParentID_FK", fields: [ParentID_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Websites_AccountGroups_WebsiteID_UK_FKToWebsites      Websites?                           @relation("AccountGroups_WebsiteID_UK_FKToWebsites", fields: [WebsiteID_UK_FK], references: [WebsiteID_PK])
  other_AccountGroups                                   AccountGroups[]                     @relation("AccountGroupsToAccountGroups_ParentID_FK")
  Accounts                                              Accounts[]
  Attachments                                           Attachments[]
  InvestmentPortfoliosAccountGroups                     InvestmentPortfoliosAccountGroups[]
  Notes                                                 Notes[]
  ReportForecastDetails                                 ReportForecastDetails[]
  ReportGoalDetails                                     ReportGoalDetails[]
  ReportsAccountGroups                                  ReportsAccountGroups[]
  Websites_AccountGroupsToWebsites_AccountGroupID_UK_FK Websites?                           @relation("AccountGroupsToWebsites_AccountGroupID_UK_FK")
}

model Accounts {
  AccountID_PK                                                                                 String                         @id
  AccountGroupID_NN_FK                                                                         String
  PayeeID_NN_UK_FK                                                                             String                         @unique(map: "sqlite_autoindex_Accounts_2")
  CategoryID_NN_UK_FK                                                                          String                         @unique(map: "sqlite_autoindex_Accounts_3")
  SecurityID_UK_FK                                                                             String?                        @unique(map: "sqlite_autoindex_Accounts_4")
  InvestmentAccountDetailsID_UK_FK                                                             String?                        @unique(map: "sqlite_autoindex_Accounts_5")
  LoanAccountDetailsID_UK_FK                                                                   String?                        @unique(map: "sqlite_autoindex_Accounts_6")
  GoalAccountDetailsID_UK_FK                                                                   String?                        @unique(map: "sqlite_autoindex_Accounts_7")
  InstitutionID_FK                                                                             String?
  DownloadConnectionID_UK_FK                                                                   String?                        @unique(map: "sqlite_autoindex_Accounts_8")
  DefaultFlagID_FK                                                                             String?
  DefaultPayeeID_FK                                                                            String?
  DefaultTransactionTypeID_FK                                                                  String?
  DefaultCategoryID_FK                                                                         String?
  WebsiteID_UK_FK                                                                              String?                        @unique(map: "sqlite_autoindex_Accounts_9")
  Position                                                                                     Int?
  TypeNumber                                                                                   Int?
  StatusNumber                                                                                 Int?
  CurrencyCode                                                                                 String?
  IncludeInBalances                                                                            Int?
  IncludeInSidebar                                                                             Int?
  IncludeInTransactions                                                                        Int?
  IncludeInGroupTransactions                                                                   Int?
  IncludeInInvestments                                                                         Int?
  IncludeInLists                                                                               Int?
  IncludeInReports                                                                             Int?
  IncludePendingTransactions                                                                   Int?
  Favorite                                                                                     Int?
  Name                                                                                         String?
  ShortName                                                                                    String?
  Info                                                                                         String?
  ColorString                                                                                  String?
  AlternateColorString                                                                         String?
  TintColorString                                                                              String?
  AlternateTintColorString                                                                     String?
  ImageData                                                                                    Bytes?
  AlternateImageData                                                                           Bytes?
  SubtitleTypeNumber                                                                           Int?
  Subtitle                                                                                     String?
  InstitutionName                                                                              String?
  InstitutionURL                                                                               String?
  RoutingNumber                                                                                String?
  Taxable                                                                                      Int?
  InterestRate                                                                                 Float?
  FeeTypeNumber                                                                                Int?
  Fee                                                                                          Float?
  PaymentDay                                                                                   Int?
  CreditLimit                                                                                  Float?
  AvailableBalance                                                                             Float?
  AvailableBalanceDate                                                                         Float?
  LedgerBalance                                                                                Float?
  LedgerBalanceDate                                                                            Float?
  MarketValue                                                                                  Float?
  MarketValueDate                                                                              Float?
  BalanceOptionTypeNumber                                                                      Int?
  MinimumBalance                                                                               Float?
  MinimumBalanceAlertTypeNumber                                                                Int?
  MinimumBalanceForAlert                                                                       Float?
  MaximumBalance                                                                               Float?
  MaximumBalanceAlertTypeNumber                                                                Int?
  MaximumBalanceForAlert                                                                       Float?
  TransactionEntryTypeNumber                                                                   Int?
  DefaultMemo                                                                                  String?
  DefaultAmount                                                                                Float?
  DefaultStatusNumber                                                                          Int?
  OFXIntuitBankID                                                                              String?
  OFXIntuitUserID                                                                              String?
  ImportSettings                                                                               Bytes?
  CheckPrintingSettings                                                                        Bytes?
  MiscValues                                                                                   Bytes?
  AccountGroups                                                                                AccountGroups                  @relation(fields: [AccountGroupID_NN_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Categories_Accounts_CategoryID_NN_UK_FKToCategories                                          Categories                     @relation("Accounts_CategoryID_NN_UK_FKToCategories", fields: [CategoryID_NN_UK_FK], references: [CategoryID_PK], onDelete: Cascade)
  Categories_Accounts_DefaultCategoryID_FKToCategories                                         Categories?                    @relation("Accounts_DefaultCategoryID_FKToCategories", fields: [DefaultCategoryID_FK], references: [CategoryID_PK])
  Flags                                                                                        Flags?                         @relation(fields: [DefaultFlagID_FK], references: [FlagID_PK])
  Payees_Accounts_DefaultPayeeID_FKToPayees                                                    Payees?                        @relation("Accounts_DefaultPayeeID_FKToPayees", fields: [DefaultPayeeID_FK], references: [PayeeID_PK])
  TransactionTypes                                                                             TransactionTypes?              @relation(fields: [DefaultTransactionTypeID_FK], references: [TransactionTypeID_PK])
  DownloadConnections_Accounts_DownloadConnectionID_UK_FKToDownloadConnections                 DownloadConnections?           @relation("Accounts_DownloadConnectionID_UK_FKToDownloadConnections", fields: [DownloadConnectionID_UK_FK], references: [DownloadConnectionID_PK])
  GoalAccountDetails_Accounts_GoalAccountDetailsID_UK_FKToGoalAccountDetails                   GoalAccountDetails?            @relation("Accounts_GoalAccountDetailsID_UK_FKToGoalAccountDetails", fields: [GoalAccountDetailsID_UK_FK], references: [GoalAccountDetailsID_PK])
  Institutions                                                                                 Institutions?                  @relation(fields: [InstitutionID_FK], references: [InstitutionID_PK])
  InvestmentAccountDetails_Accounts_InvestmentAccountDetailsID_UK_FKToInvestmentAccountDetails InvestmentAccountDetails?      @relation("Accounts_InvestmentAccountDetailsID_UK_FKToInvestmentAccountDetails", fields: [InvestmentAccountDetailsID_UK_FK], references: [InvestmentAccountDetailsID_PK])
  LoanAccountDetails_Accounts_LoanAccountDetailsID_UK_FKToLoanAccountDetails                   LoanAccountDetails?            @relation("Accounts_LoanAccountDetailsID_UK_FKToLoanAccountDetails", fields: [LoanAccountDetailsID_UK_FK], references: [LoanAccountDetailsID_PK])
  Payees_Accounts_PayeeID_NN_UK_FKToPayees                                                     Payees                         @relation("Accounts_PayeeID_NN_UK_FKToPayees", fields: [PayeeID_NN_UK_FK], references: [PayeeID_PK], onDelete: Cascade)
  Securities_Accounts_SecurityID_UK_FKToSecurities                                             Securities?                    @relation("Accounts_SecurityID_UK_FKToSecurities", fields: [SecurityID_UK_FK], references: [SecurityID_PK])
  Websites_Accounts_WebsiteID_UK_FKToWebsites                                                  Websites?                      @relation("Accounts_WebsiteID_UK_FKToWebsites", fields: [WebsiteID_UK_FK], references: [WebsiteID_PK])
  AccountBalances                                                                              AccountBalances[]
  AccountDefaultsTags                                                                          AccountDefaultsTags[]
  AccountsUsers                                                                                AccountsUsers[]
  Attachments                                                                                  Attachments[]
  BudgetsAccounts                                                                              BudgetsAccounts[]
  Categories_AccountsToCategories_AccountID_UK_FK                                              Categories?                    @relation("AccountsToCategories_AccountID_UK_FK")
  DownloadConnections_AccountsToDownloadConnections_AccountID_NN_UK_FK                         DownloadConnections?           @relation("AccountsToDownloadConnections_AccountID_NN_UK_FK")
  GoalAccountDetails_AccountsToGoalAccountDetails_AccountID_NN_UK_FK                           GoalAccountDetails?            @relation("AccountsToGoalAccountDetails_AccountID_NN_UK_FK")
  GoalAccountDetails_AccountsToGoalAccountDetails_PaymentAccountID_FK                          GoalAccountDetails[]           @relation("AccountsToGoalAccountDetails_PaymentAccountID_FK")
  ImportedAccounts                                                                             ImportedAccounts[]
  InvestmentAccountDetails_AccountsToInvestmentAccountDetails_AccountID_NN_UK_FK               InvestmentAccountDetails?      @relation("AccountsToInvestmentAccountDetails_AccountID_NN_UK_FK")
  InvestmentPortfoliosAccounts                                                                 InvestmentPortfoliosAccounts[]
  LoanAccountDetails_AccountsToLoanAccountDetails_AccountID_NN_UK_FK                           LoanAccountDetails?            @relation("AccountsToLoanAccountDetails_AccountID_NN_UK_FK")
  LoanAccountDetails_AccountsToLoanAccountDetails_PaymentAccountID_FK                          LoanAccountDetails[]           @relation("AccountsToLoanAccountDetails_PaymentAccountID_FK")
  Notes                                                                                        Notes[]
  Payees_AccountsToPayees_AccountID_UK_FK                                                      Payees?                        @relation("AccountsToPayees_AccountID_UK_FK")
  ReportForecastDetails                                                                        ReportForecastDetails[]
  ReportGoalDetails                                                                            ReportGoalDetails[]
  ReportsAccounts                                                                              ReportsAccounts[]
  ScheduledTransactions                                                                        ScheduledTransactions[]
  Securities_AccountsToSecurities_AccountID_UK_FK                                              Securities?                    @relation("AccountsToSecurities_AccountID_UK_FK")
  Statements                                                                                   Statements[]
  TransactionRuleTransactions                                                                  TransactionRuleTransactions[]
  Transactions                                                                                 Transactions[]
  Websites_AccountsToWebsites_AccountID_UK_FK                                                  Websites?                      @relation("AccountsToWebsites_AccountID_UK_FK")
}

model AccountsUsers {
  AccountID_NN_FK String
  EntityID_NN_FK  String
  DefaultUser     Int?
  PercentOwned    Float?
  Accounts        Accounts @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Entities        Entities @relation(fields: [EntityID_NN_FK], references: [EntityID_PK], onDelete: Cascade)

  @@id([AccountID_NN_FK, EntityID_NN_FK])
}

model Attachments {
  AttachmentID_PK           String                 @id
  NoteID_FK                 String?
  LocationID_FK             String?
  EntityID_FK               String?
  CreditScoreID_FK          String?
  AccountGroupID_FK         String?
  AccountID_FK              String?
  TransactionID_FK          String?
  FlagID_FK                 String?
  PayeeID_FK                String?
  TransactionTypeID_FK      String?
  CategoryID_FK             String?
  TagID_FK                  String?
  SecurityID_FK             String?
  SecurityGroupID_FK        String?
  SecurityGoalID_FK         String?
  SecurityAssetClassID_FK   String?
  SecuritySectorID_FK       String?
  SecurityIndustryID_FK     String?
  SecurityExchangeID_FK     String?
  SecurityFundCategoryID_FK String?
  SecurityFundFamilyID_FK   String?
  SecurityCustomLabelID_FK  String?
  InvestmentPortfolioID_FK  String?
  ImportedTransactionID_FK  String?
  ScheduledTransactionID_FK String?
  ExchangeRateSetID_FK      String?
  StatementID_FK            String?
  ReportID_FK               String?
  BudgetID_FK               String?
  Position                  Int?
  TypeNumber                Int?
  Name                      String?
  ShortName                 String?
  Info                      String?
  Extension                 String?
  CreationDate              Float?
  AccountGroups             AccountGroups?         @relation(fields: [AccountGroupID_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Accounts                  Accounts?              @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
  Budgets                   Budgets?               @relation(fields: [BudgetID_FK], references: [BudgetID_PK], onDelete: Cascade)
  Categories                Categories?            @relation(fields: [CategoryID_FK], references: [CategoryID_PK], onDelete: Cascade)
  CreditScores              CreditScores?          @relation(fields: [CreditScoreID_FK], references: [CreditScoreID_PK], onDelete: Cascade)
  Entities                  Entities?              @relation(fields: [EntityID_FK], references: [EntityID_PK], onDelete: Cascade)
  ExchangeRateSets          ExchangeRateSets?      @relation(fields: [ExchangeRateSetID_FK], references: [ExchangeRateSetID_PK], onDelete: Cascade)
  Flags                     Flags?                 @relation(fields: [FlagID_FK], references: [FlagID_PK], onDelete: Cascade)
  ImportedTransactions      ImportedTransactions?  @relation(fields: [ImportedTransactionID_FK], references: [ImportedTransactionID_PK], onDelete: Cascade)
  InvestmentPortfolios      InvestmentPortfolios?  @relation(fields: [InvestmentPortfolioID_FK], references: [InvestmentPortfolioID_PK])
  Locations                 Locations?             @relation(fields: [LocationID_FK], references: [LocationID_PK], onDelete: Cascade)
  Notes                     Notes?                 @relation(fields: [NoteID_FK], references: [NoteID_PK], onDelete: Cascade)
  Payees                    Payees?                @relation(fields: [PayeeID_FK], references: [PayeeID_PK], onDelete: Cascade)
  Reports                   Reports?               @relation(fields: [ReportID_FK], references: [ReportID_PK], onDelete: Cascade)
  ScheduledTransactions     ScheduledTransactions? @relation(fields: [ScheduledTransactionID_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  SecurityAssetClasses      SecurityAssetClasses?  @relation(fields: [SecurityAssetClassID_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  SecurityCustomLabels      SecurityCustomLabels?  @relation(fields: [SecurityCustomLabelID_FK], references: [SecurityCustomLabelID_PK])
  SecurityExchanges         SecurityExchanges?     @relation(fields: [SecurityExchangeID_FK], references: [SecurityExchangeID_PK])
  fundCategories            fundCategories?        @relation(fields: [SecurityFundCategoryID_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)
  SecurityFundFamilies      SecurityFundFamilies?  @relation(fields: [SecurityFundFamilyID_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)
  SecurityGoals             SecurityGoals?         @relation(fields: [SecurityGoalID_FK], references: [SecurityGoalID_PK], onDelete: Cascade)
  SecurityGroups            SecurityGroups?        @relation(fields: [SecurityGroupID_FK], references: [SecurityGroupID_PK], onDelete: Cascade)
  Securities                Securities?            @relation(fields: [SecurityID_FK], references: [SecurityID_PK], onDelete: Cascade)
  SecurityIndustries        SecurityIndustries?    @relation(fields: [SecurityIndustryID_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)
  SecuritySectors           SecuritySectors?       @relation(fields: [SecuritySectorID_FK], references: [SecuritySectorID_PK], onDelete: Cascade)
  Statements                Statements?            @relation(fields: [StatementID_FK], references: [StatementID_PK], onDelete: Cascade)
  Tags                      Tags?                  @relation(fields: [TagID_FK], references: [TagID_PK], onDelete: Cascade)
  Transactions              Transactions?          @relation(fields: [TransactionID_FK], references: [TransactionID_PK], onDelete: Cascade)
  TransactionTypes          TransactionTypes?      @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK], onDelete: Cascade)
}

model BudgetColumnDetails {
  BudgetColumnDetailsID_PK                                         String   @id
  BudgetID_NN_UK_FK                                                String   @unique(map: "sqlite_autoindex_BudgetColumnDetails_2")
  ColumnWidthTypeNumber                                            Int?
  Column1Name                                                      String?
  Column1Width                                                     Int?
  Column2Name                                                      String?
  Column2Width                                                     Int?
  Column3Name                                                      String?
  Column3Width                                                     Int?
  Column4Name                                                      String?
  Column4Width                                                     Int?
  Column5Name                                                      String?
  Column5Width                                                     Int?
  Column6Name                                                      String?
  Column6Width                                                     Int?
  Column7Name                                                      String?
  Column7Width                                                     Int?
  Column8Name                                                      String?
  Column8Width                                                     Int?
  Column9Name                                                      String?
  Column9Width                                                     Int?
  Column10Name                                                     String?
  Column10Width                                                    Int?
  Column11Name                                                     String?
  Column11Width                                                    Int?
  Column12Name                                                     String?
  Column12Width                                                    Int?
  Column13Name                                                     String?
  Column13Width                                                    Int?
  Column14Name                                                     String?
  Column14Width                                                    Int?
  Column15Name                                                     String?
  Column15Width                                                    Int?
  Column16Name                                                     String?
  Column16Width                                                    Int?
  Column17Name                                                     String?
  Column17Width                                                    Int?
  Column18Name                                                     String?
  Column18Width                                                    Int?
  Column19Name                                                     String?
  Column19Width                                                    Int?
  Column20Name                                                     String?
  Column20Width                                                    Int?
  Column21Name                                                     String?
  Column21Width                                                    Int?
  Column22Name                                                     String?
  Column22Width                                                    Int?
  Column23Name                                                     String?
  Column23Width                                                    Int?
  Column24Name                                                     String?
  Column24Width                                                    Int?
  Column25Name                                                     String?
  Column25Width                                                    Int?
  Column26Name                                                     String?
  Column26Width                                                    Int?
  Column27Name                                                     String?
  Column27Width                                                    Int?
  Column28Name                                                     String?
  Column28Width                                                    Int?
  Column29Name                                                     String?
  Column29Width                                                    Int?
  Column30Name                                                     String?
  Column30Width                                                    Int?
  Column31Name                                                     String?
  Column31Width                                                    Int?
  Column32Name                                                     String?
  Column32Width                                                    Int?
  Column33Name                                                     String?
  Column33Width                                                    Int?
  Column34Name                                                     String?
  Column34Width                                                    Int?
  Column35Name                                                     String?
  Column35Width                                                    Int?
  Column36Name                                                     String?
  Column36Width                                                    Int?
  Column37Name                                                     String?
  Column37Width                                                    Int?
  Column38Name                                                     String?
  Column38Width                                                    Int?
  Column39Name                                                     String?
  Column39Width                                                    Int?
  Column40Name                                                     String?
  Column40Width                                                    Int?
  Budgets_BudgetColumnDetails_BudgetID_NN_UK_FKToBudgets           Budgets  @relation("BudgetColumnDetails_BudgetID_NN_UK_FKToBudgets", fields: [BudgetID_NN_UK_FK], references: [BudgetID_PK], onDelete: Cascade)
  Budgets_BudgetColumnDetailsToBudgets_BudgetColumnDetailsID_UK_FK Budgets? @relation("BudgetColumnDetailsToBudgets_BudgetColumnDetailsID_UK_FK")
}

model BudgetGroups {
  BudgetGroupID_PK         String         @id
  ParentID_FK              String?
  Position                 Int?
  TypeNumber               Int?
  IncludeInSidebar         Int?
  IncludeInLists           Int?
  IncludeInBudgets         Int?
  Favorite                 Int?
  Name                     String?
  ShortName                String?
  Info                     String?
  ColorString              String?
  AlternateColorString     String?
  TintColorString          String?
  AlternateTintColorString String?
  ImageData                Bytes?
  AlternateImageData       Bytes?
  Subtitle                 String?
  BudgetGroups             BudgetGroups?  @relation("BudgetGroupsToBudgetGroups_ParentID_FK", fields: [ParentID_FK], references: [BudgetGroupID_PK], onDelete: Cascade)
  other_BudgetGroups       BudgetGroups[] @relation("BudgetGroupsToBudgetGroups_ParentID_FK")
  Budgets                  Budgets[]
}

model BudgetItemSubintervals {
  BudgetItemSubintervalID_PK String      @id
  BudgetItemID_NN_FK         String
  Position                   Int?
  DateIntervalTypeNumber     Int?
  StartDate                  Float?
  EndDate                    Float?
  BudgetedAmount             Float?
  FixedAmount                Float?
  BudgetItems                BudgetItems @relation(fields: [BudgetItemID_NN_FK], references: [BudgetItemID_PK], onDelete: Cascade)
}

model BudgetItems {
  BudgetItemID_PK           String                   @id
  ParentID_FK               String?
  Position                  Int?
  BudgetID_NN_FK            String
  CategoryID_FK             String?
  TypeNumber                Int?
  DateIntervalTypeNumber    Int?
  DateSubintervalTypeNumber Int?
  CurrencyCode              String?
  BudgetedAmountTypeNumber  Int?
  BudgetedAmount            Float?
  FixedAmount               Float?
  Budgets                   Budgets                  @relation(fields: [BudgetID_NN_FK], references: [BudgetID_PK], onDelete: Cascade)
  Categories                Categories?              @relation(fields: [CategoryID_FK], references: [CategoryID_PK], onDelete: Cascade)
  BudgetItems               BudgetItems?             @relation("BudgetItemsToBudgetItems_ParentID_FK", fields: [ParentID_FK], references: [BudgetItemID_PK], onDelete: Cascade)
  BudgetItemSubintervals    BudgetItemSubintervals[]
  other_BudgetItems         BudgetItems[]            @relation("BudgetItemsToBudgetItems_ParentID_FK")
}

model Budgets {
  BudgetID_PK                                                                  String                         @id
  BudgetGroupID_FK                                                             String?
  BudgetColumnDetailsID_UK_FK                                                  String?                        @unique(map: "sqlite_autoindex_Budgets_2")
  ExchangeRateSetID_FK                                                         String?
  Position                                                                     Int?
  TypeNumber                                                                   Int?
  OrientationTypeNumber                                                        Int?
  LayoutTypeNumber                                                             Int?
  ColorSchemeTypeNumber                                                        Int?
  GraphTypeNumber                                                              Int?
  FormatTypeNumber                                                             Int?
  DateRangeTypeNumber                                                          Int?
  StartDate                                                                    Float?
  EndDate                                                                      Float?
  DateIntervalTypeNumber                                                       Int?
  DateIntervalComparisonTypeNumber                                             Int?
  CurrencyCode                                                                 String?
  IncludeInSidebar                                                             Int?
  IncludeInLists                                                               Int?
  IncludeInReports                                                             Int?
  IncludePendingTransactions                                                   Int?
  Favorite                                                                     Int?
  Name                                                                         String?
  ShortName                                                                    String?
  Info                                                                         String?
  IncludeAccountsTypeNumber                                                    Int?
  IncludeCategoriesTypeNumber                                                  Int?
  IncludeTagsTypeNumber                                                        Int?
  IncludeScheduledTransactionsTypeNumber                                       Int?
  IncludeOtherCategoryListing                                                  Int?
  IncludeOtherIncomeCategoryListing                                            Int?
  IncludeOtherExpensesCategoryListing                                          Int?
  IncludeNoCategoryListing                                                     Int?
  IncludeNoIncomeCategoryListing                                               Int?
  IncludeNoExpensesCategoryListing                                             Int?
  IncludeNoTagListing                                                          Int?
  IncludeBalanceAdjustmentsTypeNumber                                          Int?
  IncludeTransfersTypeNumber                                                   Int?
  IncludeTransactionAmountTypeNumber                                           Int?
  IncludeTransactionStatusTypeNumber                                           Int?
  IncludeItemsPastTodayTypeNumber                                              Int?
  IncludeTotalAmountTypeNumber                                                 Int?
  ShowBudgetedItemAmountTypeOptions                                            Int?
  ScalingFactor                                                                Float?
  FontName                                                                     String?
  FontSize                                                                     Float?
  RowHeight                                                                    Float?
  HeadingColorString                                                           String?
  AlternatingRowColorString                                                    String?
  ShowAlternatingRowColor                                                      Int?
  ConstrainGraphXAxisToZero                                                    Int?
  ConstrainGraphYAxisToZero                                                    Int?
  FlipGraphDefaultAxis                                                         Int?
  NumberOfRowsValuesCanExpandInto                                              Int?
  ShowItemsWithShortNames                                                      Int?
  ShowItemsWithoutValues                                                       Int?
  ShowRowInfoAcrossTwoLines                                                    Int?
  ShowAmountsWithoutDecimals                                                   Int?
  ShowTransactionSplitDetails                                                  Int?
  ShowOtherDetails                                                             Int?
  IncludeColumnsTypeNumber                                                     Int?
  ItemSortingTypeNumber                                                        Int?
  TransactionSortingTypeNumber                                                 Int?
  MiscValues                                                                   Bytes?
  BudgetColumnDetails_BudgetColumnDetailsToBudgets_BudgetColumnDetailsID_UK_FK BudgetColumnDetails?           @relation("BudgetColumnDetailsToBudgets_BudgetColumnDetailsID_UK_FK", fields: [BudgetColumnDetailsID_UK_FK], references: [BudgetColumnDetailsID_PK])
  BudgetGroups                                                                 BudgetGroups?                  @relation(fields: [BudgetGroupID_FK], references: [BudgetGroupID_PK])
  ExchangeRateSets                                                             ExchangeRateSets?              @relation(fields: [ExchangeRateSetID_FK], references: [ExchangeRateSetID_PK])
  Attachments                                                                  Attachments[]
  BudgetColumnDetails_BudgetColumnDetails_BudgetID_NN_UK_FKToBudgets           BudgetColumnDetails?           @relation("BudgetColumnDetails_BudgetID_NN_UK_FKToBudgets")
  BudgetItems                                                                  BudgetItems[]
  BudgetsAccounts                                                              BudgetsAccounts[]
  BudgetsCategories                                                            BudgetsCategories[]
  BudgetsScheduledTransactions                                                 BudgetsScheduledTransactions[]
  BudgetsTags                                                                  BudgetsTags[]
  Notes                                                                        Notes[]
}

model BudgetsAccounts {
  BudgetID_NN_FK  String
  AccountID_NN_FK String
  Accounts        Accounts @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Budgets         Budgets  @relation(fields: [BudgetID_NN_FK], references: [BudgetID_PK], onDelete: Cascade)

  @@id([BudgetID_NN_FK, AccountID_NN_FK])
}

model BudgetsCategories {
  BudgetID_NN_FK   String
  CategoryID_NN_FK String
  Budgets          Budgets    @relation(fields: [BudgetID_NN_FK], references: [BudgetID_PK], onDelete: Cascade)
  Categories       Categories @relation(fields: [CategoryID_NN_FK], references: [CategoryID_PK], onDelete: Cascade)

  @@id([BudgetID_NN_FK, CategoryID_NN_FK])
}

model BudgetsScheduledTransactions {
  BudgetID_NN_FK               String
  ScheduledTransactionID_NN_FK String
  Budgets                      Budgets               @relation(fields: [BudgetID_NN_FK], references: [BudgetID_PK], onDelete: Cascade)
  ScheduledTransactions        ScheduledTransactions @relation(fields: [ScheduledTransactionID_NN_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)

  @@id([BudgetID_NN_FK, ScheduledTransactionID_NN_FK])
}

model BudgetsTags {
  BudgetID_NN_FK String
  TagID_NN_FK    String
  Budgets        Budgets @relation(fields: [BudgetID_NN_FK], references: [BudgetID_PK], onDelete: Cascade)
  Tags           Tags    @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)

  @@id([BudgetID_NN_FK, TagID_NN_FK])
}

model Categories {
  CategoryID_PK                                      String                        @id
  ParentID_FK                                        String?
  Position                                           Int?
  AccountID_UK_FK                                    String?                       @unique(map: "sqlite_autoindex_Categories_2")
  TaxCodeID_FK                                       String?
  TypeNumber                                         Int?
  ExpectedAmountTypeNumber                           Int?
  TaxRelated                                         Int?
  IncludeInLists                                     Int?
  IncludeInReports                                   Int?
  Favorite                                           Int?
  Name                                               String?
  ShortName                                          String?
  Info                                               String?
  ColorString                                        String?
  AlternateColorString                               String?
  TintColorString                                    String?
  AlternateTintColorString                           String?
  ImageData                                          Bytes?
  AlternateImageData                                 Bytes?
  Accounts_AccountsToCategories_AccountID_UK_FK      Accounts?                     @relation("AccountsToCategories_AccountID_UK_FK", fields: [AccountID_UK_FK], references: [AccountID_PK])
  Categories                                         Categories?                   @relation("CategoriesToCategories_ParentID_FK", fields: [ParentID_FK], references: [CategoryID_PK], onDelete: Cascade)
  TaxCodes                                           TaxCodes?                     @relation(fields: [TaxCodeID_FK], references: [TaxCodeID_PK])
  Accounts_Accounts_CategoryID_NN_UK_FKToCategories  Accounts?                     @relation("Accounts_CategoryID_NN_UK_FKToCategories")
  Accounts_Accounts_DefaultCategoryID_FKToCategories Accounts[]                    @relation("Accounts_DefaultCategoryID_FKToCategories")
  Attachments                                        Attachments[]
  BudgetItems                                        BudgetItems[]
  BudgetsCategories                                  BudgetsCategories[]
  other_Categories                                   Categories[]                  @relation("CategoriesToCategories_ParentID_FK")
  LoanTransactionDetails                             LoanTransactionDetails[]
  Notes                                              Notes[]
  ReportForecastDetails                              ReportForecastDetails[]
  ReportGoalDetails                                  ReportGoalDetails[]
  ReportsCategories                                  ReportsCategories[]
  ScheduledTransactions                              ScheduledTransactions[]
  TransactionRuleTransactions                        TransactionRuleTransactions[]
  Transactions                                       Transactions[]
}

model CreditScores {
  CreditScoreID_PK      String                  @id
  EntityID_NN_FK        String
  TypeNumber            Int?
  Name                  String?
  ShortName             String?
  Info                  String?
  Date                  Float?
  ScoreNumber           Int?
  ScoreString           String?
  Entities              Entities                @relation(fields: [EntityID_NN_FK], references: [EntityID_PK], onDelete: Cascade)
  Attachments           Attachments[]
  Notes                 Notes[]
  ReportForecastDetails ReportForecastDetails[]
  ReportGoalDetails     ReportGoalDetails[]
  ReportsCreditScores   ReportsCreditScores[]
}

model DownloadConnections {
  DownloadConnectionID_PK                                           String               @id
  AccountID_NN_UK_FK                                                String               @unique(map: "sqlite_autoindex_DownloadConnections_2")
  InstitutionCustomerID_NN_FK                                       String
  OFXBankID                                                         String?
  OFXBrokerID                                                       String?
  OFXAccountTypeNumber                                              Int?
  LastOFXSignOnResponseCode                                         String?
  LastOFXSignOnResponseSeverity                                     String?
  LastOFXSignOnResponseMessage                                      String?
  LastOFXAccountResponseCode                                        String?
  LastOFXAccountResponseSeverity                                    String?
  LastOFXAccountResponseMessage                                     String?
  LastOFXTransactionRequestDate                                     Float?
  LastOFXTransactionRequestEndDate                                  Float?
  LastSuccessfulOFXTransactionRequestDate                           Float?
  LastSuccessfulOFXTransactionRequestEndDate                        Float?
  Accounts_AccountsToDownloadConnections_AccountID_NN_UK_FK         Accounts             @relation("AccountsToDownloadConnections_AccountID_NN_UK_FK", fields: [AccountID_NN_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  InstitutionCustomers                                              InstitutionCustomers @relation(fields: [InstitutionCustomerID_NN_FK], references: [InstitutionCustomerID_PK], onDelete: Cascade)
  Accounts_Accounts_DownloadConnectionID_UK_FKToDownloadConnections Accounts?            @relation("Accounts_DownloadConnectionID_UK_FKToDownloadConnections")
}

model Entities {
  EntityID_PK                              String                         @id
  PayeeID_NN_UK_FK                         String                         @unique(map: "sqlite_autoindex_Entities_2")
  Position                                 Int?
  TypeNumber                               Int?
  Name                                     String?
  ShortName                                String?
  Info                                     String?
  ColorString                              String?
  AlternateColorString                     String?
  TintColorString                          String?
  AlternateTintColorString                 String?
  ImageData                                Bytes?
  AlternateImageData                       Bytes?
  CountryCodeForTaxes                      String?
  IdentifierTypeNumber                     Int?
  Identifier                               String?
  Birthdate                                Float?
  Payees_Entities_PayeeID_NN_UK_FKToPayees Payees                         @relation("Entities_PayeeID_NN_UK_FKToPayees", fields: [PayeeID_NN_UK_FK], references: [PayeeID_PK], onDelete: Cascade)
  AccountsUsers                            AccountsUsers[]
  Attachments                              Attachments[]
  CreditScores                             CreditScores[]
  InvestmentPortfoliosEntities             InvestmentPortfoliosEntities[]
  Notes                                    Notes[]
  Payees_EntitiesToPayees_EntityID_UK_FK   Payees?                        @relation("EntitiesToPayees_EntityID_UK_FK")
  ReportForecastDetails                    ReportForecastDetails[]
  ReportGoalDetails                        ReportGoalDetails[]
  ReportsEntities                          ReportsEntities[]
  ScheduledTransactions                    ScheduledTransactions[]
  TransactionRuleTransactions              TransactionRuleTransactions[]
  Transactions                             Transactions[]
}

model ExchangeRateSets {
  ExchangeRateSetID_PK String          @id
  TypeNumber           Int?
  Name                 String?
  ShortName            String?
  Info                 String?
  Date                 Float?
  Attachments          Attachments[]
  Budgets              Budgets[]
  ExchangeRates        ExchangeRates[]
  Notes                Notes[]
  Reports              Reports[]
}

model ExchangeRates {
  ExchangeRateID_PK        String            @id
  ExchangeRateSetID_FK     String?
  UpdateBehaviorTypeNumber Int?
  BaseCurrencyCode         String?
  TermCurrencyCode         String?
  ExchangeRate             Float?
  ExchangeRateAsOfDate     Float?
  ExchangeRateSets         ExchangeRateSets? @relation(fields: [ExchangeRateSetID_FK], references: [ExchangeRateSetID_PK], onDelete: Cascade)
}

model Flags {
  FlagID_PK                   String                        @id
  TypeNumber                  Int?
  StyleNumber                 Int?
  BehaviorNumber              Int?
  IncludeInLists              Int?
  IncludeInReports            Int?
  Favorite                    Int?
  Name                        String?
  ShortName                   String?
  Info                        String?
  ColorString                 String?
  AlternateColorString        String?
  TintColorString             String?
  AlternateTintColorString    String?
  ImageData                   Bytes?
  AlternateImageData          Bytes?
  Accounts                    Accounts[]
  Attachments                 Attachments[]
  Notes                       Notes[]
  ReportsFlags                ReportsFlags[]
  ScheduledTransactions       ScheduledTransactions[]
  TransactionRuleTransactions TransactionRuleTransactions[]
  Transactions                Transactions[]
}

model GoalAccountDetails {
  GoalAccountDetailsID_PK                                                                      String                 @id
  AccountID_NN_UK_FK                                                                           String                 @unique(map: "sqlite_autoindex_GoalAccountDetails_2")
  PaymentAccountID_FK                                                                          String?
  ScheduledTransactionID_UK_FK                                                                 String?                @unique(map: "sqlite_autoindex_GoalAccountDetails_3")
  TypeNumber                                                                                   Int?
  GoalAmount                                                                                   Float?
  StartDate                                                                                    Float?
  EndDate                                                                                      Float?
  DateIntervalTypeNumber                                                                       Int?
  PeriodicAmount                                                                               Float?
  HasOfferedToSetupSchedule                                                                    Int?
  MiscValues                                                                                   Bytes?
  Accounts_AccountsToGoalAccountDetails_AccountID_NN_UK_FK                                     Accounts               @relation("AccountsToGoalAccountDetails_AccountID_NN_UK_FK", fields: [AccountID_NN_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  Accounts_AccountsToGoalAccountDetails_PaymentAccountID_FK                                    Accounts?              @relation("AccountsToGoalAccountDetails_PaymentAccountID_FK", fields: [PaymentAccountID_FK], references: [AccountID_PK])
  ScheduledTransactions_GoalAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions ScheduledTransactions? @relation("GoalAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions", fields: [ScheduledTransactionID_UK_FK], references: [ScheduledTransactionID_PK])
  Accounts_Accounts_GoalAccountDetailsID_UK_FKToGoalAccountDetails                             Accounts?              @relation("Accounts_GoalAccountDetailsID_UK_FKToGoalAccountDetails")
  ScheduledTransactions_GoalAccountDetailsToScheduledTransactions_GoalAccountDetailsID_UK_FK   ScheduledTransactions? @relation("GoalAccountDetailsToScheduledTransactions_GoalAccountDetailsID_UK_FK")
}

model HistoricalPrices {
  HistoricalPriceID_PK String     @id
  SecurityID_NN_FK     String
  OriginNumber         Int?
  Date                 Float?
  Open                 Float?
  High                 Float?
  Low                  Float?
  Close                Float?
  Volume               Float?
  AdjustedClose        Float?
  Securities           Securities @relation(fields: [SecurityID_NN_FK], references: [SecurityID_PK], onDelete: Cascade)
}

model ImportLogs {
  ImportLogID_PK                                String   @id
  ImportID_NN_UK_FK                             String   @unique(map: "sqlite_autoindex_ImportLogs_2")
  TypeNumber                                    Int?
  Name                                          String?
  Extension                                     String?
  Log                                           String?
  Imports_ImportLogs_ImportID_NN_UK_FKToImports Imports  @relation("ImportLogs_ImportID_NN_UK_FKToImports", fields: [ImportID_NN_UK_FK], references: [ImportID_PK], onDelete: Cascade)
  Imports_ImportLogsToImports_ImportLogID_UK_FK Imports? @relation("ImportLogsToImports_ImportLogID_UK_FK")
}

model ImportedAccounts {
  ImportedAccountID_PK String                 @id
  ImportID_NN_FK       String
  AccountID_NN_FK      String
  OrderInImport        Int?
  TypeNumber           Int?
  CurrencyCode         String?
  NameInImport         String?
  ActualAccountName    String?
  InstitutionName      String?
  Info                 String?
  RequestedStartDate   Float?
  RequestedEndDate     Float?
  StartDate            Float?
  EndDate              Float?
  FirstTransactionDate Float?
  LastTransactionDate  Float?
  StartingBalance      Float?
  AvailableBalance     Float?
  AvailableBalanceDate Float?
  LedgerBalance        Float?
  LedgerBalanceDate    Float?
  InterestRate         Float?
  CreditLimit          Float?
  Imported             Int?
  ImportedForCreating  Int?
  Accounts             Accounts               @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Imports              Imports                @relation(fields: [ImportID_NN_FK], references: [ImportID_PK], onDelete: Cascade)
  ImportedTransactions ImportedTransactions[]
}

model ImportedInvestmentTransactionDetails {
  ImportedInvestmentTransactionDetailsID_PK                                                                                    String                @id
  ImportedTransactionID_NN_UK_FK                                                                                               String                @unique(map: "sqlite_autoindex_ImportedInvestmentTransactionDetails_2")
  SecurityAction                                                                                                               String?
  Name                                                                                                                         String?
  IdentifierTypeNumber                                                                                                         Int?
  Identifier                                                                                                                   String?
  Symbol                                                                                                                       String?
  FundingTypeNumber                                                                                                            Int?
  EffectiveDate                                                                                                                Float?
  Units                                                                                                                        Float?
  UnitPrice                                                                                                                    Float?
  Commission                                                                                                                   Float?
  ImportedTransactions_ImportedInvestmentTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions               ImportedTransactions  @relation("ImportedInvestmentTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions", fields: [ImportedTransactionID_NN_UK_FK], references: [ImportedTransactionID_PK], onDelete: Cascade)
  ImportedTransactions_ImportedInvestmentTransactionDetailsToImportedTransactions_ImportedInvestmentTransactionDetailsID_UK_FK ImportedTransactions? @relation("ImportedInvestmentTransactionDetailsToImportedTransactions_ImportedInvestmentTransactionDetailsID_UK_FK")
}

model ImportedLoanTransactionDetails {
  ImportedLoanTransactionDetailsID_PK                                                                              String                @id
  ImportedTransactionID_NN_UK_FK                                                                                   String                @unique(map: "sqlite_autoindex_ImportedLoanTransactionDetails_2")
  ImportedTransactions_ImportedLoanTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions         ImportedTransactions  @relation("ImportedLoanTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions", fields: [ImportedTransactionID_NN_UK_FK], references: [ImportedTransactionID_PK], onDelete: Cascade)
  ImportedTransactions_ImportedLoanTransactionDetailsToImportedTransactions_ImportedLoanTransactionDetailsID_UK_FK ImportedTransactions? @relation("ImportedLoanTransactionDetailsToImportedTransactions_ImportedLoanTransactionDetailsID_UK_FK")
}

model ImportedTransactions {
  ImportedTransactionID_PK                                                                                                                     String                                @id
  ParentID_FK                                                                                                                                  String?
  Position                                                                                                                                     Int?
  ImportedAccountID_FK                                                                                                                         String?
  ImportedInvestmentTransactionDetailsID_UK_FK                                                                                                 String?                               @unique(map: "sqlite_autoindex_ImportedTransactions_2")
  ImportedLoanTransactionDetailsID_UK_FK                                                                                                       String?                               @unique(map: "sqlite_autoindex_ImportedTransactions_3")
  TransactionID_UK_FK                                                                                                                          String?                               @unique(map: "sqlite_autoindex_ImportedTransactions_4")
  OrderInImport                                                                                                                                Int?
  UniqueID                                                                                                                                     String?
  OriginalCurrencyCode                                                                                                                         String?
  OriginalCurrencyRate                                                                                                                         Float?
  DateString                                                                                                                                   String?
  Date                                                                                                                                         Float?
  ClearedDate                                                                                                                                  Float?
  Payee                                                                                                                                        String?
  TransactionType                                                                                                                              String?
  TransactionTypeTypeNumber                                                                                                                    Int?
  Category                                                                                                                                     String?
  Tags                                                                                                                                         String?
  Memo                                                                                                                                         String?
  CheckNumber                                                                                                                                  String?
  TransactionNumber                                                                                                                            String?
  Amount                                                                                                                                       Float?
  AmountAppliedToBalance                                                                                                                       Float?
  StatusNumber                                                                                                                                 Int?
  Imported                                                                                                                                     Int?
  ActionNumber                                                                                                                                 Int?
  ImportedAccounts                                                                                                                             ImportedAccounts?                     @relation(fields: [ImportedAccountID_FK], references: [ImportedAccountID_PK])
  ImportedInvestmentTransactionDetails_ImportedInvestmentTransactionDetailsToImportedTransactions_ImportedInvestmentTransactionDetailsID_UK_FK ImportedInvestmentTransactionDetails? @relation("ImportedInvestmentTransactionDetailsToImportedTransactions_ImportedInvestmentTransactionDetailsID_UK_FK", fields: [ImportedInvestmentTransactionDetailsID_UK_FK], references: [ImportedInvestmentTransactionDetailsID_PK])
  ImportedLoanTransactionDetails_ImportedLoanTransactionDetailsToImportedTransactions_ImportedLoanTransactionDetailsID_UK_FK                   ImportedLoanTransactionDetails?       @relation("ImportedLoanTransactionDetailsToImportedTransactions_ImportedLoanTransactionDetailsID_UK_FK", fields: [ImportedLoanTransactionDetailsID_UK_FK], references: [ImportedLoanTransactionDetailsID_PK])
  ImportedTransactions                                                                                                                         ImportedTransactions?                 @relation("ImportedTransactionsToImportedTransactions_ParentID_FK", fields: [ParentID_FK], references: [ImportedTransactionID_PK], onDelete: Cascade)
  Transactions_ImportedTransactions_TransactionID_UK_FKToTransactions                                                                          Transactions?                         @relation("ImportedTransactions_TransactionID_UK_FKToTransactions", fields: [TransactionID_UK_FK], references: [TransactionID_PK])
  Attachments                                                                                                                                  Attachments[]
  ImportedInvestmentTransactionDetails_ImportedInvestmentTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions               ImportedInvestmentTransactionDetails? @relation("ImportedInvestmentTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions")
  ImportedLoanTransactionDetails_ImportedLoanTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions                           ImportedLoanTransactionDetails?       @relation("ImportedLoanTransactionDetails_ImportedTransactionID_NN_UK_FKToImportedTransactions")
  other_ImportedTransactions                                                                                                                   ImportedTransactions[]                @relation("ImportedTransactionsToImportedTransactions_ParentID_FK")
  Transactions_ImportedTransactionsToTransactions_ImportedTransactionID_UK_FK                                                                  Transactions?                         @relation("ImportedTransactionsToTransactions_ImportedTransactionID_UK_FK")
}

model Imports {
  ImportID_PK                                      String             @id
  ImportLogID_UK_FK                                String?            @unique(map: "sqlite_autoindex_Imports_2")
  StatementID_UK_FK                                String?            @unique(map: "sqlite_autoindex_Imports_3")
  TypeNumber                                       Int?
  FileTypeNumber                                   Int?
  OriginNumber                                     Int?
  Date                                             Float?
  UserName                                         String?
  HardwareUUID                                     String?
  DeviceName                                       String?
  StartDate                                        Float?
  EndDate                                          Float?
  FirstTransactionDate                             Float?
  LastTransactionDate                              Float?
  ImportLogs_ImportLogsToImports_ImportLogID_UK_FK ImportLogs?        @relation("ImportLogsToImports_ImportLogID_UK_FK", fields: [ImportLogID_UK_FK], references: [ImportLogID_PK])
  Statements_Imports_StatementID_UK_FKToStatements Statements?        @relation("Imports_StatementID_UK_FKToStatements", fields: [StatementID_UK_FK], references: [StatementID_PK], onDelete: Cascade)
  ImportLogs_ImportLogs_ImportID_NN_UK_FKToImports ImportLogs?        @relation("ImportLogs_ImportID_NN_UK_FKToImports")
  ImportedAccounts                                 ImportedAccounts[]
  Statements_ImportsToStatements_ImportID_UK_FK    Statements?        @relation("ImportsToStatements_ImportID_UK_FK")
}

model InstitutionCustomers {
  InstitutionCustomerID_PK String                @id
  InstitutionID_NN_FK      String
  OFXClientID              String?
  OFXHasChangedPIN         Int?
  Institutions             Institutions          @relation(fields: [InstitutionID_NN_FK], references: [InstitutionID_PK], onDelete: Cascade)
  DownloadConnections      DownloadConnections[]
}

model Institutions {
  InstitutionID_PK                  String                 @id
  TypeNumber                        Int?
  SCCode                            String?
  AllowsDirectConnect               Int?
  AllowsWebConnect                  Int?
  AllowsExpressWebConnect           Int?
  Name                              String?
  ShortName                         String?
  Info                              String?
  ColorString                       String?
  AlternateColorString              String?
  TintColorString                   String?
  AlternateTintColorString          String?
  ImageData                         Bytes?
  AlternateImageData                Bytes?
  Address1                          String?
  Address2                          String?
  Address3                          String?
  City                              String?
  State                             String?
  ZipCode                           String?
  Country                           String?
  CustomerServicePhone              String?
  TechnicalSupportPhone             String?
  WebsiteURL                        String?
  LogoURL                           String?
  OFXLastProfileRequestDate         Float?
  OFXAppID                          String?
  OFXAppVersion                     String?
  OFXURL                            String?
  OFXHeader                         String?
  OFXVersion                        String?
  OFXOrg                            String?
  OFXFID                            String?
  OFXBankID                         String?
  OFXIntuitBankID                   String?
  OFXBrokerID                       String?
  OFXPINMinCharacters               Int?
  OFXPINMaxCharacters               Int?
  OFXPINCharacterType               String?
  OFXPINCaseSensitive               Int?
  OFXPINAllowSpecialCharacters      Int?
  OFXPINAllowSpaceCharacters        Int?
  OFXCanChangePin                   Int?
  OFXChangePinFirst                 Int?
  OFXClientIDRequired               Int?
  OFXAccountDiscoveryAvailable      Int?
  OFXDirectConnectSetupOptionNumber Int?
  OFXSendRequestsWithLineBreaks     Int?
  OFXAddTrailingSlashToRequestURLs  Int?
  OFXSignOnURL                      String?
  OFXSignUpURL                      String?
  OFXBankURL                        String?
  OFXCreditCardURL                  String?
  OFXLoanURL                        String?
  OFXInvestmentURL                  String?
  OFXInterbankTransferURL           String?
  OFXWireTransferURL                String?
  OFXBillPayURL                     String?
  OFXEmailURL                       String?
  OFXSecurityListURL                String?
  OFXBillerDirectoryURL             String?
  OFXBillDeliveryURL                String?
  OFXProfileURL                     String?
  OFXImageDownloadURL               String?
  Accounts                          Accounts[]
  InstitutionCustomers              InstitutionCustomers[]
}

model InvestmentAccountDetails {
  InvestmentAccountDetailsID_PK                                                String      @id
  AccountID_NN_UK_FK                                                           String      @unique(map: "sqlite_autoindex_InvestmentAccountDetails_2")
  DefaultSecurityID_FK                                                         String?
  DefaultEquityLotTrackingTypeNumber                                           Int?
  DefaultMutualFundLotTrackingTypeNumber                                       Int?
  DefaultDebtInstrumentLotTrackingTypeNumber                                   Int?
  DefaultDerivativeLotTrackingTypeNumber                                       Int?
  DefaultOtherLotTrackingTypeNumber                                            Int?
  MiscValues                                                                   Bytes?
  Accounts_AccountsToInvestmentAccountDetails_AccountID_NN_UK_FK               Accounts    @relation("AccountsToInvestmentAccountDetails_AccountID_NN_UK_FK", fields: [AccountID_NN_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  Securities                                                                   Securities? @relation(fields: [DefaultSecurityID_FK], references: [SecurityID_PK])
  Accounts_Accounts_InvestmentAccountDetailsID_UK_FKToInvestmentAccountDetails Accounts?   @relation("Accounts_InvestmentAccountDetailsID_UK_FKToInvestmentAccountDetails")
}

model InvestmentAccountPositionMarketValues {
  InvestmentAccountPositionMarketValueID_PK String                      @id
  InvestmentAccountPositionID_FK            String?
  Date                                      Float?
  Units                                     Float?
  UnitPrice                                 Float?
  InvestmentAccountPositions                InvestmentAccountPositions? @relation(fields: [InvestmentAccountPositionID_FK], references: [InvestmentAccountPositionID_PK], onDelete: Cascade)
}

model InvestmentAccountPositions {
  InvestmentAccountPositionID_PK         String                                  @id
  InvestmentAggregatePositionID_FK       String?
  TypeNumber                             Int?
  OpenDate                               Float?
  AdjustedUnits                          Float?
  AdjustedTotalAmount                    Float?
  AdjustedCostBasis                      Float?
  AdjustedSalesProceeds                  Float?
  RealizedUnits                          Float?
  RealizedShortTermUnits                 Float?
  RealizedLongTermUnits                  Float?
  RealizedCosts                          Float?
  RealizedShortTermCosts                 Float?
  RealizedLongTermCosts                  Float?
  RealizedPurchaseAmount                 Float?
  RealizedShortTermPurchaseAmount        Float?
  RealizedLongTermPurchaseAmount         Float?
  RealizedPurchaseCosts                  Float?
  RealizedShortTermPurchaseCosts         Float?
  RealizedLongTermPurchaseCosts          Float?
  RealizedCostBasis                      Float?
  RealizedShortTermCostBasis             Float?
  RealizedLongTermCostBasis              Float?
  RealizedIncomeAmount                   Float?
  RealizedShortTermIncomeAmount          Float?
  RealizedLongTermIncomeAmount           Float?
  RealizedIncomeCosts                    Float?
  RealizedShortTermIncomeCosts           Float?
  RealizedLongTermIncomeCosts            Float?
  RealizedInterestIncomeAmount           Float?
  RealizedShortTermInterestIncomeAmount  Float?
  RealizedLongTermInterestIncomeAmount   Float?
  RealizedInterestIncomeCosts            Float?
  RealizedShortTermInterestIncomeCosts   Float?
  RealizedLongTermInterestIncomeCosts    Float?
  RealizedInterestExpenseAmount          Float?
  RealizedShortTermInterestExpenseAmount Float?
  RealizedLongTermInterestExpenseAmount  Float?
  RealizedInterestExpenseCosts           Float?
  RealizedShortTermInterestExpenseCosts  Float?
  RealizedLongTermInterestExpenseCosts   Float?
  RealizedMiscIncomeAmount               Float?
  RealizedShortTermMiscIncomeAmount      Float?
  RealizedLongTermMiscIncomeAmount       Float?
  RealizedMiscIncomeCosts                Float?
  RealizedShortTermMiscIncomeCosts       Float?
  RealizedLongTermMiscIncomeCosts        Float?
  RealizedMiscExpenseAmount              Float?
  RealizedShortTermMiscExpenseAmount     Float?
  RealizedLongTermMiscExpenseAmount      Float?
  RealizedMiscExpenseCosts               Float?
  RealizedShortTermMiscExpenseCosts      Float?
  RealizedLongTermMiscExpenseCosts       Float?
  RealizedSalesAmount                    Float?
  RealizedShortTermSalesAmount           Float?
  RealizedLongTermSalesAmount            Float?
  RealizedSalesCosts                     Float?
  RealizedShortTermSalesCosts            Float?
  RealizedLongTermSalesCosts             Float?
  RealizedSalesProceeds                  Float?
  RealizedShortTermSalesProceeds         Float?
  RealizedLongTermSalesProceeds          Float?
  RealizedGainLoss                       Float?
  RealizedPercentGainLoss                Float?
  RealizedShortTermGainLoss              Float?
  RealizedShortTermPercentGainLoss       Float?
  RealizedLongTermGainLoss               Float?
  RealizedLongTermPercentGainLoss        Float?
  RealizedReturn                         Float?
  RealizedShortTermReturn                Float?
  RealizedLongTermReturn                 Float?
  OutstandingUnits                       Float?
  OutstandingCostBasis                   Float?
  OutstandingSalesProceeds               Float?
  InvestmentAggregatePositions           InvestmentAggregatePositions?           @relation(fields: [InvestmentAggregatePositionID_FK], references: [InvestmentAggregatePositionID_PK])
  InvestmentAccountPositionMarketValues  InvestmentAccountPositionMarketValues[]
  InvestmentTransactionDetails           InvestmentTransactionDetails[]
}

model InvestmentAggregatePositionMarketValues {
  InvestmentAggregatePositionMarketValueID_PK String                        @id
  InvestmentAggregatePositionID_FK            String?
  Date                                        Float?
  Units                                       Float?
  UnitPrice                                   Float?
  InvestmentAggregatePositions                InvestmentAggregatePositions? @relation(fields: [InvestmentAggregatePositionID_FK], references: [InvestmentAggregatePositionID_PK], onDelete: Cascade)
}

model InvestmentAggregatePositions {
  InvestmentAggregatePositionID_PK        String                                    @id
  TypeNumber                              Int?
  OpenDate                                Float?
  AdjustedUnits                           Float?
  RealizedUnits                           Float?
  RealizedShortTermUnits                  Float?
  RealizedLongTermUnits                   Float?
  OutstandingUnits                        Float?
  InvestmentAccountPositions              InvestmentAccountPositions[]
  InvestmentAggregatePositionMarketValues InvestmentAggregatePositionMarketValues[]
}

model InvestmentPortfolios {
  InvestmentPortfolioID_PK                   String                                       @id
  ParentID_FK                                String?
  Position                                   Int?
  TypeNumber                                 Int?
  DateRangeTypeNumber                        Int?
  UseCurrentDate                             Int?
  Date                                       Float?
  StartDate                                  Float?
  EndDate                                    Float?
  IncludeInLists                             Int?
  IncludeInReports                           Int?
  IncludePendingTransactions                 Int?
  Favorite                                   Int?
  Name                                       String?
  ShortName                                  String?
  Info                                       String?
  ColorString                                String?
  AlternateColorString                       String?
  TintColorString                            String?
  AlternateTintColorString                   String?
  ImageData                                  Bytes?
  AlternateImageData                         Bytes?
  IncludeEntitiesTypeNumber                  Int?
  IncludeAccountGroupsTypeNumber             Int?
  IncludeAccountsTypeNumber                  Int?
  IncludeSecurityTypesTypeNumber             Int?
  IncludeSecuritiesTypeNumber                Int?
  IncludeSecurityGroupsTypeNumber            Int?
  IncludeSecurityGoalsTypeNumber             Int?
  IncludeSecurityAssetClassesTypeNumber      Int?
  IncludeSecuritySectorsTypeNumber           Int?
  IncludeSecurityIndustriesTypeNumber        Int?
  IncludeSecurityExchangesTypeNumber         Int?
  IncludeSecurityFundCategoriesTypeNumber    Int?
  IncludeSecurityFundFamiliesTypeNumber      Int?
  IncludeSecurityCustomLabelsTypeNumber      Int?
  InvestmentPortfolios                       InvestmentPortfolios?                        @relation("InvestmentPortfoliosToInvestmentPortfolios_ParentID_FK", fields: [ParentID_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  Attachments                                Attachments[]
  other_InvestmentPortfolios                 InvestmentPortfolios[]                       @relation("InvestmentPortfoliosToInvestmentPortfolios_ParentID_FK")
  InvestmentPortfoliosAccountGroups          InvestmentPortfoliosAccountGroups[]
  InvestmentPortfoliosAccounts               InvestmentPortfoliosAccounts[]
  InvestmentPortfoliosEntities               InvestmentPortfoliosEntities[]
  InvestmentPortfoliosSecurities             InvestmentPortfoliosSecurities[]
  InvestmentPortfoliosSecurityAssetClasses   InvestmentPortfoliosSecurityAssetClasses[]
  InvestmentPortfoliosSecurityCustomLabels   InvestmentPortfoliosSecurityCustomLabels[]
  InvestmentPortfoliosSecurityExchanges      InvestmentPortfoliosSecurityExchanges[]
  InvestmentPortfoliosSecurityFundCategories InvestmentPortfoliosSecurityFundCategories[]
  InvestmentPortfoliosSecurityFundFamilies   InvestmentPortfoliosSecurityFundFamilies[]
  InvestmentPortfoliosSecurityGoals          InvestmentPortfoliosSecurityGoals[]
  InvestmentPortfoliosSecurityGroups         InvestmentPortfoliosSecurityGroups[]
  InvestmentPortfoliosSecurityIndustries     InvestmentPortfoliosSecurityIndustries[]
  InvestmentPortfoliosSecuritySectors        InvestmentPortfoliosSecuritySectors[]
  InvestmentPortfoliosSecurityTypes          InvestmentPortfoliosSecurityTypes[]
  Notes                                      Notes[]
  ReportForecastDetails                      ReportForecastDetails[]
  ReportGoalDetails                          ReportGoalDetails[]
  ReportsInvestmentPortfolios                ReportsInvestmentPortfolios[]
}

model InvestmentPortfoliosAccountGroups {
  InvestmentPortfolioID_NN_FK String
  AccountGroupID_NN_FK        String
  AccountGroups               AccountGroups        @relation(fields: [AccountGroupID_NN_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, AccountGroupID_NN_FK])
}

model InvestmentPortfoliosAccounts {
  InvestmentPortfolioID_NN_FK String
  AccountID_NN_FK             String
  Accounts                    Accounts             @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, AccountID_NN_FK])
}

model InvestmentPortfoliosEntities {
  InvestmentPortfolioID_NN_FK String
  EntityID_NN_FK              String
  Entities                    Entities             @relation(fields: [EntityID_NN_FK], references: [EntityID_PK], onDelete: Cascade)
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, EntityID_NN_FK])
}

model InvestmentPortfoliosSecurities {
  InvestmentPortfolioID_NN_FK String
  SecurityID_NN_FK            String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  Securities                  Securities           @relation(fields: [SecurityID_NN_FK], references: [SecurityID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityID_NN_FK])
}

model InvestmentPortfoliosSecurityAssetClasses {
  InvestmentPortfolioID_NN_FK String
  SecurityAssetClassID_NN_FK  String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityAssetClasses        SecurityAssetClasses @relation(fields: [SecurityAssetClassID_NN_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityAssetClassID_NN_FK])
}

model InvestmentPortfoliosSecurityCustomLabels {
  InvestmentPortfolioID_NN_FK String
  SecurityCustomLabelID_NN_FK String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityCustomLabels        SecurityCustomLabels @relation(fields: [SecurityCustomLabelID_NN_FK], references: [SecurityCustomLabelID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityCustomLabelID_NN_FK])
}

model InvestmentPortfoliosSecurityExchanges {
  InvestmentPortfolioID_NN_FK String
  SecurityExchangeID_NN_FK    String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityExchanges           SecurityExchanges    @relation(fields: [SecurityExchangeID_NN_FK], references: [SecurityExchangeID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityExchangeID_NN_FK])
}

model InvestmentPortfoliosSecurityFundCategories {
  InvestmentPortfolioID_NN_FK  String
  SecurityFundCategoryID_NN_FK String
  InvestmentPortfolios         InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  fundCategories               fundCategories       @relation(fields: [SecurityFundCategoryID_NN_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityFundCategoryID_NN_FK])
}

model InvestmentPortfoliosSecurityFundFamilies {
  InvestmentPortfolioID_NN_FK String
  SecurityFundFamilyID_NN_FK  String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityFundFamilies        SecurityFundFamilies @relation(fields: [SecurityFundFamilyID_NN_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityFundFamilyID_NN_FK])
}

model InvestmentPortfoliosSecurityGoals {
  InvestmentPortfolioID_NN_FK String
  SecurityGoalID_NN_FK        String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityGoals               SecurityGoals        @relation(fields: [SecurityGoalID_NN_FK], references: [SecurityGoalID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityGoalID_NN_FK])
}

model InvestmentPortfoliosSecurityGroups {
  InvestmentPortfolioID_NN_FK String
  SecurityGroupID_NN_FK       String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityGroups              SecurityGroups       @relation(fields: [SecurityGroupID_NN_FK], references: [SecurityGroupID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityGroupID_NN_FK])
}

model InvestmentPortfoliosSecurityIndustries {
  InvestmentPortfolioID_NN_FK String
  SecurityIndustryID_NN_FK    String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityIndustries          SecurityIndustries   @relation(fields: [SecurityIndustryID_NN_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityIndustryID_NN_FK])
}

model InvestmentPortfoliosSecuritySectors {
  InvestmentPortfolioID_NN_FK String
  SecuritySectorID_NN_FK      String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecuritySectors             SecuritySectors      @relation(fields: [SecuritySectorID_NN_FK], references: [SecuritySectorID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecuritySectorID_NN_FK])
}

model InvestmentPortfoliosSecurityTypes {
  InvestmentPortfolioID_NN_FK String
  SecurityTypeID_NN_FK        String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  SecurityTypes               SecurityTypes        @relation(fields: [SecurityTypeID_NN_FK], references: [SecurityTypeID_PK], onDelete: Cascade)

  @@id([InvestmentPortfolioID_NN_FK, SecurityTypeID_NN_FK])
}

model InvestmentTransactionDetails {
  InvestmentTransactionDetailsID_PK                                                                                                           String                             @id
  TransactionID_UK_FK                                                                                                                         String?                            @unique(map: "sqlite_autoindex_InvestmentTransactionDetails_2")
  ScheduledTransactionID_UK_FK                                                                                                                String?                            @unique(map: "sqlite_autoindex_InvestmentTransactionDetails_3")
  TransactionRuleTransactionID_UK_FK                                                                                                          String?                            @unique(map: "sqlite_autoindex_InvestmentTransactionDetails_4")
  SecurityID_FK                                                                                                                               String?
  InvestmentAccountPositionID_FK                                                                                                              String?
  LotTrackingTypeNumber                                                                                                                       Int?
  EffectTypeNumber                                                                                                                            Int?
  EffectiveDate                                                                                                                               Float?
  OriginalSecurityCurrencyRate                                                                                                                Float?
  Units                                                                                                                                       Float?
  UnitPrice                                                                                                                                   Float?
  Commission                                                                                                                                  Float?
  OtherAmountTypeNumber                                                                                                                       Int?
  OtherAmount                                                                                                                                 Float?
  TotalAmount                                                                                                                                 Float?
  AdjustedUnits                                                                                                                               Float?
  AdjustedTotalAmount                                                                                                                         Float?
  AdjustedCostBasis                                                                                                                           Float?
  AdjustedSalesProceeds                                                                                                                       Float?
  RealizedUnits                                                                                                                               Float?
  RealizedCostBasis                                                                                                                           Float?
  RealizedSalesProceeds                                                                                                                       Float?
  RealizedGainLoss                                                                                                                            Float?
  RealizedPercentGainLoss                                                                                                                     Float?
  RealizedReturn                                                                                                                              Float?
  OutstandingUnits                                                                                                                            Float?
  OutstandingCostBasis                                                                                                                        Float?
  OutstandingSalesProceeds                                                                                                                    Float?
  RunningPositionRealizedUnits                                                                                                                Float?
  RunningPositionRealizedCostBasis                                                                                                            Float?
  RunningPositionRealizedSalesProceeds                                                                                                        Float?
  RunningPositionRealizedGainLoss                                                                                                             Float?
  RunningPositionRealizedPercentGainLoss                                                                                                      Float?
  RunningPositionRealizedReturn                                                                                                               Float?
  RunningPositionOutstandingUnits                                                                                                             Float?
  RunningPositionOutstandingCostBasis                                                                                                         Float?
  RunningPositionOutstandingSalesProceeds                                                                                                     Float?
  InvestmentAccountPositions                                                                                                                  InvestmentAccountPositions?        @relation(fields: [InvestmentAccountPositionID_FK], references: [InvestmentAccountPositionID_PK])
  ScheduledTransactions_InvestmentTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions                                      ScheduledTransactions?             @relation("InvestmentTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions", fields: [ScheduledTransactionID_UK_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  Securities                                                                                                                                  Securities?                        @relation(fields: [SecurityID_FK], references: [SecurityID_PK])
  Transactions_InvestmentTransactionDetails_TransactionID_UK_FKToTransactions                                                                 Transactions?                      @relation("InvestmentTransactionDetails_TransactionID_UK_FKToTransactions", fields: [TransactionID_UK_FK], references: [TransactionID_PK], onDelete: Cascade)
  TransactionRuleTransactions_InvestmentTransactionDetails_TransactionRuleTransactionID_UK_FKToTransactionRuleTransactions                    TransactionRuleTransactions?       @relation("InvestmentTransactionDetails_TransactionRuleTransactionID_UK_FKToTransactionRuleTransactions", fields: [TransactionRuleTransactionID_UK_FK], references: [TransactionRuleTransactionID_PK], onDelete: Cascade)
  InvestmentTransactionDetailsLots_InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_ClosingInvestmentTransactionDetailsID_NN_FK InvestmentTransactionDetailsLots[] @relation("InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_ClosingInvestmentTransactionDetailsID_NN_FK")
  InvestmentTransactionDetailsLots_InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_OpeningInvestmentTransactionDetailsID_NN_FK InvestmentTransactionDetailsLots[] @relation("InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_OpeningInvestmentTransactionDetailsID_NN_FK")
  ScheduledTransactions_InvestmentTransactionDetailsToScheduledTransactions_InvestmentTransactionDetailsID_UK_FK                              ScheduledTransactions?             @relation("InvestmentTransactionDetailsToScheduledTransactions_InvestmentTransactionDetailsID_UK_FK")
  TransactionRuleTransactions_InvestmentTransactionDetailsToTransactionRuleTransactions_InvestmentTransactionDetailsID_UK_FK                  TransactionRuleTransactions?       @relation("InvestmentTransactionDetailsToTransactionRuleTransactions_InvestmentTransactionDetailsID_UK_FK")
  Transactions_InvestmentTransactionDetailsToTransactions_InvestmentTransactionDetailsID_UK_FK                                                Transactions?                      @relation("InvestmentTransactionDetailsToTransactions_InvestmentTransactionDetailsID_UK_FK")
}

model InvestmentTransactionDetailsLots {
  OpeningInvestmentTransactionDetailsID_NN_FK                                                                                             String
  ClosingInvestmentTransactionDetailsID_NN_FK                                                                                             String
  DateAcquired                                                                                                                            Float?
  DateRelinquished                                                                                                                        Float?
  Units                                                                                                                                   Float?
  CostBasis                                                                                                                               Float?
  SalesProceeds                                                                                                                           Float?
  InvestmentTransactionDetails_InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_ClosingInvestmentTransactionDetailsID_NN_FK InvestmentTransactionDetails @relation("InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_ClosingInvestmentTransactionDetailsID_NN_FK", fields: [ClosingInvestmentTransactionDetailsID_NN_FK], references: [InvestmentTransactionDetailsID_PK], onDelete: Cascade)
  InvestmentTransactionDetails_InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_OpeningInvestmentTransactionDetailsID_NN_FK InvestmentTransactionDetails @relation("InvestmentTransactionDetailsToInvestmentTransactionDetailsLots_OpeningInvestmentTransactionDetailsID_NN_FK", fields: [OpeningInvestmentTransactionDetailsID_NN_FK], references: [InvestmentTransactionDetailsID_PK], onDelete: Cascade)

  @@id([OpeningInvestmentTransactionDetailsID_NN_FK, ClosingInvestmentTransactionDetailsID_NN_FK])
}

model LoanAccountDetails {
  LoanAccountDetailsID_PK                                                                      String                 @id
  AccountID_NN_UK_FK                                                                           String                 @unique(map: "sqlite_autoindex_LoanAccountDetails_2")
  PaymentAccountID_FK                                                                          String?
  ScheduledTransactionID_UK_FK                                                                 String?                @unique(map: "sqlite_autoindex_LoanAccountDetails_3")
  TypeNumber                                                                                   Int?
  AmortizationTypeNumber                                                                       Int?
  BehaviorTypeNumber                                                                           Int?
  InitialLoanAmount                                                                            Float?
  NumberOfPeriods                                                                              Int?
  InterestRate                                                                                 Float?
  CompoundingTypeNumber                                                                        Int?
  DayCountConventionTypeNumber                                                                 Int?
  RoundingTypeNumber                                                                           Int?
  InitialLoanDate                                                                              Float?
  FirstPaymentDate                                                                             Float?
  DateIntervalTypeNumber                                                                       Int?
  HasOfferedToSetupSchedule                                                                    Int?
  MiscValues                                                                                   Bytes?
  Accounts_AccountsToLoanAccountDetails_AccountID_NN_UK_FK                                     Accounts               @relation("AccountsToLoanAccountDetails_AccountID_NN_UK_FK", fields: [AccountID_NN_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  Accounts_AccountsToLoanAccountDetails_PaymentAccountID_FK                                    Accounts?              @relation("AccountsToLoanAccountDetails_PaymentAccountID_FK", fields: [PaymentAccountID_FK], references: [AccountID_PK])
  ScheduledTransactions_LoanAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions ScheduledTransactions? @relation("LoanAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions", fields: [ScheduledTransactionID_UK_FK], references: [ScheduledTransactionID_PK])
  Accounts_Accounts_LoanAccountDetailsID_UK_FKToLoanAccountDetails                             Accounts?              @relation("Accounts_LoanAccountDetailsID_UK_FKToLoanAccountDetails")
  LoanPaymentSegments                                                                          LoanPaymentSegments[]
  LoanPayments                                                                                 LoanPayments[]
  ScheduledTransactions_LoanAccountDetailsToScheduledTransactions_LoanAccountDetailsID_UK_FK   ScheduledTransactions? @relation("LoanAccountDetailsToScheduledTransactions_LoanAccountDetailsID_UK_FK")
}

model LoanPaymentSegments {
  LoanPaymentSegmentID_PK    String                   @id
  LoanAccountDetailsID_NN_FK String
  InitialPrincipalBalance    Float?
  FirstPaymentPeriodNumber   Int?
  LastPaymentPeriodNumber    Int?
  FirstPaymentDate           Float?
  InterestRate               Float?
  PrincipalAmount            Float?
  InterestAmount             Float?
  OtherAmounts               Float?
  TotalPayment               Float?
  CalculatePaymentAmount     Int?
  LoanAccountDetails         LoanAccountDetails       @relation(fields: [LoanAccountDetailsID_NN_FK], references: [LoanAccountDetailsID_PK], onDelete: Cascade)
  LoanPayments               LoanPayments[]
  LoanTransactionDetails     LoanTransactionDetails[]
}

model LoanPayments {
  LoanPaymentID_PK           String                   @id
  LoanAccountDetailsID_NN_FK String
  LoanPaymentSegmentID_NN_FK String
  InitialPrincipalBalance    Float?
  PaymentPeriodNumber        Int?
  PaymentDate                Float?
  InterestRate               Float?
  PrincipalAmount            Float?
  InterestAmount             Float?
  OtherAmounts               Float?
  TotalPayment               Float?
  CalculatePaymentAmount     Int?
  LoanAccountDetails         LoanAccountDetails       @relation(fields: [LoanAccountDetailsID_NN_FK], references: [LoanAccountDetailsID_PK], onDelete: Cascade)
  LoanPaymentSegments        LoanPaymentSegments      @relation(fields: [LoanPaymentSegmentID_NN_FK], references: [LoanPaymentSegmentID_PK], onDelete: Cascade)
  LoanTransactionDetails     LoanTransactionDetails[]
}

model LoanTransactionDetails {
  LoanTransactionDetailsID_PK                                                                        String                       @id
  LoanPaymentSegmentID_FK                                                                            String?
  LoanPaymentID_FK                                                                                   String?
  TransactionID_UK_FK                                                                                String?                      @unique(map: "sqlite_autoindex_LoanTransactionDetails_2")
  ScheduledTransactionID_UK_FK                                                                       String?                      @unique(map: "sqlite_autoindex_LoanTransactionDetails_3")
  PayeeID_FK                                                                                         String?
  TransactionTypeID_FK                                                                               String?
  CategoryID_FK                                                                                      String?
  Position                                                                                           Int?
  TypeNumber                                                                                         Int?
  Memo                                                                                               String?
  Amount                                                                                             Float?
  Categories                                                                                         Categories?                  @relation(fields: [CategoryID_FK], references: [CategoryID_PK])
  LoanPayments                                                                                       LoanPayments?                @relation(fields: [LoanPaymentID_FK], references: [LoanPaymentID_PK], onDelete: Cascade)
  LoanPaymentSegments                                                                                LoanPaymentSegments?         @relation(fields: [LoanPaymentSegmentID_FK], references: [LoanPaymentSegmentID_PK], onDelete: Cascade)
  Payees                                                                                             Payees?                      @relation(fields: [PayeeID_FK], references: [PayeeID_PK])
  ScheduledTransactions_LoanTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions   ScheduledTransactions?       @relation("LoanTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions", fields: [ScheduledTransactionID_UK_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  Transactions_LoanTransactionDetails_TransactionID_UK_FKToTransactions                              Transactions?                @relation("LoanTransactionDetails_TransactionID_UK_FKToTransactions", fields: [TransactionID_UK_FK], references: [TransactionID_PK], onDelete: Cascade)
  TransactionTypes                                                                                   TransactionTypes?            @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK])
  LoanTransactionDetailsTags                                                                         LoanTransactionDetailsTags[]
  ScheduledTransactions_LoanTransactionDetailsToScheduledTransactions_LoanTransactionDetailsID_UK_FK ScheduledTransactions?       @relation("LoanTransactionDetailsToScheduledTransactions_LoanTransactionDetailsID_UK_FK")
  Transactions_LoanTransactionDetailsToTransactions_LoanTransactionDetailsID_UK_FK                   Transactions?                @relation("LoanTransactionDetailsToTransactions_LoanTransactionDetailsID_UK_FK")
}

model LoanTransactionDetailsTags {
  LoanTransactionDetailsID_NN_FK String
  TagID_NN_FK                    String
  LoanTransactionDetails         LoanTransactionDetails @relation(fields: [LoanTransactionDetailsID_NN_FK], references: [LoanTransactionDetailsID_PK], onDelete: Cascade)
  Tags                           Tags                   @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)

  @@id([LoanTransactionDetailsID_NN_FK, TagID_NN_FK])
}

model Locations {
  LocationID_PK                                 String        @id
  PayeeID_NN_FK                                 String
  WebsiteID_UK_FK                               String?       @unique(map: "sqlite_autoindex_Locations_2")
  Position                                      Int?
  TypeNumber                                    Int?
  Favorite                                      Int?
  Name                                          String?
  ShortName                                     String?
  Info                                          String?
  ColorString                                   String?
  AlternateColorString                          String?
  TintColorString                               String?
  AlternateTintColorString                      String?
  ImageData                                     Bytes?
  AlternateImageData                            Bytes?
  LocationNumber                                String?
  Latitude                                      Float?
  Longitude                                     Float?
  GooglePlaceID                                 String?
  OtherPlaceID                                  String?
  Address1                                      String?
  Address2                                      String?
  Address3                                      String?
  City                                          String?
  State                                         String?
  ZipCode                                       String?
  CountryCode                                   String?
  TimeZoneName                                  String?
  Phone                                         String?
  Fax                                           String?
  Email                                         String?
  Payees                                        Payees        @relation(fields: [PayeeID_NN_FK], references: [PayeeID_PK], onDelete: Cascade)
  Websites_Locations_WebsiteID_UK_FKToWebsites  Websites?     @relation("Locations_WebsiteID_UK_FKToWebsites", fields: [WebsiteID_UK_FK], references: [WebsiteID_PK])
  Attachments                                   Attachments[]
  Notes                                         Notes[]
  Websites_LocationsToWebsites_LocationID_UK_FK Websites?     @relation("LocationsToWebsites_LocationID_UK_FK")
}

model Notes {
  NoteID_PK                 String                 @id
  LocationID_FK             String?
  EntityID_FK               String?
  CreditScoreID_FK          String?
  AccountGroupID_FK         String?
  AccountID_FK              String?
  TransactionID_FK          String?
  FlagID_FK                 String?
  PayeeID_FK                String?
  TransactionTypeID_FK      String?
  CategoryID_FK             String?
  TagID_FK                  String?
  SecurityID_FK             String?
  SecurityGroupID_FK        String?
  SecurityGoalID_FK         String?
  SecurityAssetClassID_FK   String?
  SecuritySectorID_FK       String?
  SecurityIndustryID_FK     String?
  SecurityExchangeID_FK     String?
  SecurityFundCategoryID_FK String?
  SecurityFundFamilyID_FK   String?
  SecurityCustomLabelID_FK  String?
  InvestmentPortfolioID_FK  String?
  ScheduledTransactionID_FK String?
  ExchangeRateSetID_FK      String?
  StatementID_FK            String?
  ReportID_FK               String?
  BudgetID_FK               String?
  Position                  Int?
  TypeNumber                Int?
  LayoutTypeNumber          Int?
  CreationDate              Float?
  ModifiedDate              Float?
  PriorityNumber            Int?
  Name                      String?
  ShortName                 String?
  Info                      String?
  Note                      String?
  NoteTextAttributes        Bytes?
  AccountGroups             AccountGroups?         @relation(fields: [AccountGroupID_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Accounts                  Accounts?              @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
  Budgets                   Budgets?               @relation(fields: [BudgetID_FK], references: [BudgetID_PK], onDelete: Cascade)
  Categories                Categories?            @relation(fields: [CategoryID_FK], references: [CategoryID_PK], onDelete: Cascade)
  CreditScores              CreditScores?          @relation(fields: [CreditScoreID_FK], references: [CreditScoreID_PK], onDelete: Cascade)
  Entities                  Entities?              @relation(fields: [EntityID_FK], references: [EntityID_PK], onDelete: Cascade)
  ExchangeRateSets          ExchangeRateSets?      @relation(fields: [ExchangeRateSetID_FK], references: [ExchangeRateSetID_PK], onDelete: Cascade)
  Flags                     Flags?                 @relation(fields: [FlagID_FK], references: [FlagID_PK], onDelete: Cascade)
  InvestmentPortfolios      InvestmentPortfolios?  @relation(fields: [InvestmentPortfolioID_FK], references: [InvestmentPortfolioID_PK])
  Locations                 Locations?             @relation(fields: [LocationID_FK], references: [LocationID_PK], onDelete: Cascade)
  Payees                    Payees?                @relation(fields: [PayeeID_FK], references: [PayeeID_PK], onDelete: Cascade)
  Reports                   Reports?               @relation(fields: [ReportID_FK], references: [ReportID_PK], onDelete: Cascade)
  ScheduledTransactions     ScheduledTransactions? @relation(fields: [ScheduledTransactionID_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  SecurityAssetClasses      SecurityAssetClasses?  @relation(fields: [SecurityAssetClassID_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  SecurityCustomLabels      SecurityCustomLabels?  @relation(fields: [SecurityCustomLabelID_FK], references: [SecurityCustomLabelID_PK])
  SecurityExchanges         SecurityExchanges?     @relation(fields: [SecurityExchangeID_FK], references: [SecurityExchangeID_PK])
  fundCategories            fundCategories?        @relation(fields: [SecurityFundCategoryID_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)
  SecurityFundFamilies      SecurityFundFamilies?  @relation(fields: [SecurityFundFamilyID_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)
  SecurityGoals             SecurityGoals?         @relation(fields: [SecurityGoalID_FK], references: [SecurityGoalID_PK], onDelete: Cascade)
  SecurityGroups            SecurityGroups?        @relation(fields: [SecurityGroupID_FK], references: [SecurityGroupID_PK], onDelete: Cascade)
  Securities                Securities?            @relation(fields: [SecurityID_FK], references: [SecurityID_PK], onDelete: Cascade)
  SecurityIndustries        SecurityIndustries?    @relation(fields: [SecurityIndustryID_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)
  SecuritySectors           SecuritySectors?       @relation(fields: [SecuritySectorID_FK], references: [SecuritySectorID_PK], onDelete: Cascade)
  Statements                Statements?            @relation(fields: [StatementID_FK], references: [StatementID_PK], onDelete: Cascade)
  Tags                      Tags?                  @relation(fields: [TagID_FK], references: [TagID_PK], onDelete: Cascade)
  Transactions              Transactions?          @relation(fields: [TransactionID_FK], references: [TransactionID_PK], onDelete: Cascade)
  TransactionTypes          TransactionTypes?      @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK], onDelete: Cascade)
  Attachments               Attachments[]
}

model ObjectMatches {
  ObjectMatchID_PK                  String            @id
  ParentID_FK                       String?
  Position                          Int?
  TransactionRuleID_FK              String?
  ReportID_FK                       String?
  TypeNumber                        Int?
  CombinationTypeNumber             Int?
  ClassTypeNumber                   Int?
  ClassPropertyTypeNumber           Int?
  ObjectTypeSpecific                Int?
  ObjectTypeNumber                  Int?
  ObjectOptionTypeSpecific          Int?
  ObjectOptionTypeNumber            Int?
  ObjectOptionTypeTypeNumber        Int?
  GenericMatchingTypeNumber         Int?
  StringMatchingTypeNumber          Int?
  StringValue                       String?
  StringValue1                      String?
  StringValue2                      String?
  NumberMatchingTypeNumber          Int?
  NumberValue                       Float?
  NumberValue1                      Float?
  NumberValue2                      Float?
  TreatStringValuesAsNumbers        Int?
  TreatNumberValuesAsAbsoluteValues Int?
  TaxSpecific                       Int?
  TaxSpecificTypeNumber             Int?
  ObjectMatches                     ObjectMatches?    @relation("ObjectMatchesToObjectMatches_ParentID_FK", fields: [ParentID_FK], references: [ObjectMatchID_PK], onDelete: Cascade)
  Reports                           Reports?          @relation(fields: [ReportID_FK], references: [ReportID_PK], onDelete: Cascade)
  TransactionRules                  TransactionRules? @relation(fields: [TransactionRuleID_FK], references: [TransactionRuleID_PK], onDelete: Cascade)
  other_ObjectMatches               ObjectMatches[]   @relation("ObjectMatchesToObjectMatches_ParentID_FK")
}

model Payees {
  PayeeID_PK                                                        String                        @id
  EntityID_UK_FK                                                    String?                       @unique(map: "sqlite_autoindex_Payees_2")
  AccountID_UK_FK                                                   String?                       @unique(map: "sqlite_autoindex_Payees_3")
  TransactionRuleID_UK_FK                                           String?                       @unique(map: "sqlite_autoindex_Payees_4")
  WebsiteID_UK_FK                                                   String?                       @unique(map: "sqlite_autoindex_Payees_5")
  TypeNumber                                                        Int?
  IncludeInLists                                                    Int?
  IncludeInReports                                                  Int?
  Favorite                                                          Int?
  Name                                                              String?
  ShortName                                                         String?
  Info                                                              String?
  ColorString                                                       String?
  AlternateColorString                                              String?
  TintColorString                                                   String?
  AlternateTintColorString                                          String?
  ImageData                                                         Bytes?
  AlternateImageData                                                Bytes?
  IdentifierTypeNumber                                              Int?
  Identifier                                                        String?
  Accounts_AccountsToPayees_AccountID_UK_FK                         Accounts?                     @relation("AccountsToPayees_AccountID_UK_FK", fields: [AccountID_UK_FK], references: [AccountID_PK])
  Entities_EntitiesToPayees_EntityID_UK_FK                          Entities?                     @relation("EntitiesToPayees_EntityID_UK_FK", fields: [EntityID_UK_FK], references: [EntityID_PK])
  TransactionRules_Payees_TransactionRuleID_UK_FKToTransactionRules TransactionRules?             @relation("Payees_TransactionRuleID_UK_FKToTransactionRules", fields: [TransactionRuleID_UK_FK], references: [TransactionRuleID_PK])
  Websites_Payees_WebsiteID_UK_FKToWebsites                         Websites?                     @relation("Payees_WebsiteID_UK_FKToWebsites", fields: [WebsiteID_UK_FK], references: [WebsiteID_PK])
  Accounts_Accounts_DefaultPayeeID_FKToPayees                       Accounts[]                    @relation("Accounts_DefaultPayeeID_FKToPayees")
  Accounts_Accounts_PayeeID_NN_UK_FKToPayees                        Accounts?                     @relation("Accounts_PayeeID_NN_UK_FKToPayees")
  Attachments                                                       Attachments[]
  Entities_Entities_PayeeID_NN_UK_FKToPayees                        Entities?                     @relation("Entities_PayeeID_NN_UK_FKToPayees")
  LoanTransactionDetails                                            LoanTransactionDetails[]
  Locations                                                         Locations[]
  Notes                                                             Notes[]
  ReportForecastDetails                                             ReportForecastDetails[]
  ReportGoalDetails                                                 ReportGoalDetails[]
  ReportsPayees                                                     ReportsPayees[]
  ScheduledTransactions                                             ScheduledTransactions[]
  TransactionRuleTransactions                                       TransactionRuleTransactions[]
  TransactionRules_PayeesToTransactionRules_PayeeID_UK_FK           TransactionRules?             @relation("PayeesToTransactionRules_PayeeID_UK_FK")
  Transactions                                                      Transactions[]
  Websites_PayeesToWebsites_PayeeID_UK_FK                           Websites?                     @relation("PayeesToWebsites_PayeeID_UK_FK")
}

model ReportColumnDetails {
  ReportColumnDetailsID_PK                                         String   @id
  ReportID_NN_UK_FK                                                String   @unique(map: "sqlite_autoindex_ReportColumnDetails_2")
  ColumnWidthTypeNumber                                            Int?
  Column1Name                                                      String?
  Column1Width                                                     Int?
  Column2Name                                                      String?
  Column2Width                                                     Int?
  Column3Name                                                      String?
  Column3Width                                                     Int?
  Column4Name                                                      String?
  Column4Width                                                     Int?
  Column5Name                                                      String?
  Column5Width                                                     Int?
  Column6Name                                                      String?
  Column6Width                                                     Int?
  Column7Name                                                      String?
  Column7Width                                                     Int?
  Column8Name                                                      String?
  Column8Width                                                     Int?
  Column9Name                                                      String?
  Column9Width                                                     Int?
  Column10Name                                                     String?
  Column10Width                                                    Int?
  Column11Name                                                     String?
  Column11Width                                                    Int?
  Column12Name                                                     String?
  Column12Width                                                    Int?
  Column13Name                                                     String?
  Column13Width                                                    Int?
  Column14Name                                                     String?
  Column14Width                                                    Int?
  Column15Name                                                     String?
  Column15Width                                                    Int?
  Column16Name                                                     String?
  Column16Width                                                    Int?
  Column17Name                                                     String?
  Column17Width                                                    Int?
  Column18Name                                                     String?
  Column18Width                                                    Int?
  Column19Name                                                     String?
  Column19Width                                                    Int?
  Column20Name                                                     String?
  Column20Width                                                    Int?
  Column21Name                                                     String?
  Column21Width                                                    Int?
  Column22Name                                                     String?
  Column22Width                                                    Int?
  Column23Name                                                     String?
  Column23Width                                                    Int?
  Column24Name                                                     String?
  Column24Width                                                    Int?
  Column25Name                                                     String?
  Column25Width                                                    Int?
  Column26Name                                                     String?
  Column26Width                                                    Int?
  Column27Name                                                     String?
  Column27Width                                                    Int?
  Column28Name                                                     String?
  Column28Width                                                    Int?
  Column29Name                                                     String?
  Column29Width                                                    Int?
  Column30Name                                                     String?
  Column30Width                                                    Int?
  Column31Name                                                     String?
  Column31Width                                                    Int?
  Column32Name                                                     String?
  Column32Width                                                    Int?
  Column33Name                                                     String?
  Column33Width                                                    Int?
  Column34Name                                                     String?
  Column34Width                                                    Int?
  Column35Name                                                     String?
  Column35Width                                                    Int?
  Column36Name                                                     String?
  Column36Width                                                    Int?
  Column37Name                                                     String?
  Column37Width                                                    Int?
  Column38Name                                                     String?
  Column38Width                                                    Int?
  Column39Name                                                     String?
  Column39Width                                                    Int?
  Column40Name                                                     String?
  Column40Width                                                    Int?
  Reports_ReportColumnDetails_ReportID_NN_UK_FKToReports           Reports  @relation("ReportColumnDetails_ReportID_NN_UK_FKToReports", fields: [ReportID_NN_UK_FK], references: [ReportID_PK], onDelete: Cascade)
  Reports_ReportColumnDetailsToReports_ReportColumnDetailsID_UK_FK Reports? @relation("ReportColumnDetailsToReports_ReportColumnDetailsID_UK_FK")
}

model ReportForecastDetails {
  ReportForecastDetailsID_PK   String                @id
  ReportID_NN_FK               String
  EntityID_FK                  String?
  CreditScoreID_FK             String?
  AccountGroupID_FK            String?
  AccountID_FK                 String?
  PayeeID_FK                   String?
  TransactionTypeID_FK         String?
  CategoryID_FK                String?
  TagID_FK                     String?
  SecurityTypeID_FK            String?
  SecurityID_FK                String?
  SecurityGroupID_FK           String?
  SecurityGoalID_FK            String?
  SecurityAssetClassID_FK      String?
  SecuritySectorID_FK          String?
  SecurityIndustryID_FK        String?
  SecurityExchangeID_FK        String?
  SecurityFundCategoryID_FK    String?
  SecurityFundFamilyID_FK      String?
  SecurityCustomLabelID_FK     String?
  InvestmentPortfolioID_FK     String?
  Position                     Int?
  TypeNumber                   Int?
  BaseAmount                   Float?
  ChangeTypeNumber             Int?
  ChangeDateIntervalTypeNumber Int?
  ChangeAmount                 Float?
  StartDate                    Float?
  EndDate                      Float?
  ExpectedInflation            Float?
  MiscValues                   Bytes?
  AccountGroups                AccountGroups?        @relation(fields: [AccountGroupID_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Accounts                     Accounts?             @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
  Categories                   Categories?           @relation(fields: [CategoryID_FK], references: [CategoryID_PK], onDelete: Cascade)
  CreditScores                 CreditScores?         @relation(fields: [CreditScoreID_FK], references: [CreditScoreID_PK], onDelete: Cascade)
  Entities                     Entities?             @relation(fields: [EntityID_FK], references: [EntityID_PK], onDelete: Cascade)
  InvestmentPortfolios         InvestmentPortfolios? @relation(fields: [InvestmentPortfolioID_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  Payees                       Payees?               @relation(fields: [PayeeID_FK], references: [PayeeID_PK], onDelete: Cascade)
  Reports                      Reports               @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityAssetClasses         SecurityAssetClasses? @relation(fields: [SecurityAssetClassID_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  SecurityCustomLabels         SecurityCustomLabels? @relation(fields: [SecurityCustomLabelID_FK], references: [SecurityCustomLabelID_PK], onDelete: Cascade)
  SecurityExchanges            SecurityExchanges?    @relation(fields: [SecurityExchangeID_FK], references: [SecurityExchangeID_PK], onDelete: Cascade)
  fundCategories               fundCategories?       @relation(fields: [SecurityFundCategoryID_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)
  SecurityFundFamilies         SecurityFundFamilies? @relation(fields: [SecurityFundFamilyID_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)
  SecurityGoals                SecurityGoals?        @relation(fields: [SecurityGoalID_FK], references: [SecurityGoalID_PK], onDelete: Cascade)
  SecurityGroups               SecurityGroups?       @relation(fields: [SecurityGroupID_FK], references: [SecurityGroupID_PK], onDelete: Cascade)
  Securities                   Securities?           @relation(fields: [SecurityID_FK], references: [SecurityID_PK], onDelete: Cascade)
  SecurityIndustries           SecurityIndustries?   @relation(fields: [SecurityIndustryID_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)
  SecuritySectors              SecuritySectors?      @relation(fields: [SecuritySectorID_FK], references: [SecuritySectorID_PK], onDelete: Cascade)
  SecurityTypes                SecurityTypes?        @relation(fields: [SecurityTypeID_FK], references: [SecurityTypeID_PK], onDelete: Cascade)
  Tags                         Tags?                 @relation(fields: [TagID_FK], references: [TagID_PK], onDelete: Cascade)
  TransactionTypes             TransactionTypes?     @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK], onDelete: Cascade)
}

model ReportGoalDetails {
  ReportGoalDetailsID_PK            String                @id
  ReportID_NN_FK                    String
  EntityID_FK                       String?
  CreditScoreID_FK                  String?
  AccountGroupID_FK                 String?
  AccountID_FK                      String?
  PayeeID_FK                        String?
  TransactionTypeID_FK              String?
  CategoryID_FK                     String?
  TagID_FK                          String?
  SecurityTypeID_FK                 String?
  SecurityID_FK                     String?
  SecurityGroupID_FK                String?
  SecurityGoalID_FK                 String?
  SecuritySectorID_FK               String?
  SecurityAssetClassID_FK           String?
  SecurityIndustryID_FK             String?
  SecurityExchangeID_FK             String?
  SecurityFundCategoryID_FK         String?
  SecurityFundFamilyID_FK           String?
  SecurityCustomLabelID_FK          String?
  InvestmentPortfolioID_FK          String?
  Position                          Int?
  TypeNumber                        Int?
  BaseAmount                        Float?
  ChangeTypeNumber                  Int?
  ChangeDateIntervalTypeNumber      Int?
  ChangeAmount                      Float?
  StartDate                         Float?
  EndDate                           Float?
  ExpectedInflation                 Float?
  AcceptableMarginOfErrorTypeNumber Int?
  AcceptableMarginOfErrorAmount     Float?
  MiscValues                        Bytes?
  AccountGroups                     AccountGroups?        @relation(fields: [AccountGroupID_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Accounts                          Accounts?             @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
  Categories                        Categories?           @relation(fields: [CategoryID_FK], references: [CategoryID_PK], onDelete: Cascade)
  CreditScores                      CreditScores?         @relation(fields: [CreditScoreID_FK], references: [CreditScoreID_PK], onDelete: Cascade)
  Entities                          Entities?             @relation(fields: [EntityID_FK], references: [EntityID_PK], onDelete: Cascade)
  InvestmentPortfolios              InvestmentPortfolios? @relation(fields: [InvestmentPortfolioID_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  Payees                            Payees?               @relation(fields: [PayeeID_FK], references: [PayeeID_PK], onDelete: Cascade)
  Reports                           Reports               @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityAssetClasses              SecurityAssetClasses? @relation(fields: [SecurityAssetClassID_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  SecurityCustomLabels              SecurityCustomLabels? @relation(fields: [SecurityCustomLabelID_FK], references: [SecurityCustomLabelID_PK], onDelete: Cascade)
  SecurityExchanges                 SecurityExchanges?    @relation(fields: [SecurityExchangeID_FK], references: [SecurityExchangeID_PK], onDelete: Cascade)
  fundCategories                    fundCategories?       @relation(fields: [SecurityFundCategoryID_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)
  SecurityFundFamilies              SecurityFundFamilies? @relation(fields: [SecurityFundFamilyID_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)
  SecurityGoals                     SecurityGoals?        @relation(fields: [SecurityGoalID_FK], references: [SecurityGoalID_PK], onDelete: Cascade)
  SecurityGroups                    SecurityGroups?       @relation(fields: [SecurityGroupID_FK], references: [SecurityGroupID_PK], onDelete: Cascade)
  Securities                        Securities?           @relation(fields: [SecurityID_FK], references: [SecurityID_PK], onDelete: Cascade)
  SecurityIndustries                SecurityIndustries?   @relation(fields: [SecurityIndustryID_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)
  SecuritySectors                   SecuritySectors?      @relation(fields: [SecuritySectorID_FK], references: [SecuritySectorID_PK], onDelete: Cascade)
  SecurityTypes                     SecurityTypes?        @relation(fields: [SecurityTypeID_FK], references: [SecurityTypeID_PK], onDelete: Cascade)
  Tags                              Tags?                 @relation(fields: [TagID_FK], references: [TagID_PK], onDelete: Cascade)
  TransactionTypes                  TransactionTypes?     @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK], onDelete: Cascade)
}

model ReportGroups {
  ReportGroupID_PK         String         @id
  ParentID_FK              String?
  Position                 Int?
  TypeNumber               Int?
  IncludeInSidebar         Int?
  IncludeInLists           Int?
  IncludeInReports         Int?
  Favorite                 Int?
  Name                     String?
  ShortName                String?
  Info                     String?
  ColorString              String?
  AlternateColorString     String?
  TintColorString          String?
  AlternateTintColorString String?
  ImageData                Bytes?
  AlternateImageData       Bytes?
  Subtitle                 String?
  ReportGroups             ReportGroups?  @relation("ReportGroupsToReportGroups_ParentID_FK", fields: [ParentID_FK], references: [ReportGroupID_PK], onDelete: Cascade)
  other_ReportGroups       ReportGroups[] @relation("ReportGroupsToReportGroups_ParentID_FK")
  Reports                  Reports[]
}

model Reports {
  ReportID_PK                                                                  String                          @id
  ReportGroupID_FK                                                             String?
  ReportColumnDetailsID_UK_FK                                                  String?                         @unique(map: "sqlite_autoindex_Reports_2")
  ExchangeRateSetID_FK                                                         String?
  Position                                                                     Int?
  TypeNumber                                                                   Int?
  OrientationTypeNumber                                                        Int?
  LayoutTypeNumber                                                             Int?
  ColorSchemeTypeNumber                                                        Int?
  GraphTypeNumber                                                              Int?
  FormatTypeNumber                                                             Int?
  DateRangeTypeNumber                                                          Int?
  UseCurrentDate                                                               Int?
  Date                                                                         Float?
  StartDate                                                                    Float?
  EndDate                                                                      Float?
  DateIntervalTypeNumber                                                       Int?
  DateIntervalComparisonTypeNumber                                             Int?
  ComparisonDateRangeTypeNumber                                                Int?
  ComparisonUseCurrentDate                                                     Int?
  ComparisonDate                                                               Float?
  ComparisonStartDate                                                          Float?
  ComparisonEndDate                                                            Float?
  ComparisonDateIntervalTypeNumber                                             Int?
  GroupingTypeNumber                                                           Int?
  SubgroupingTypeNumber                                                        Int?
  CurrencyCode                                                                 String?
  IncludeInSidebar                                                             Int?
  IncludeInLists                                                               Int?
  IncludeInReports                                                             Int?
  IncludePendingTransactions                                                   Int?
  Favorite                                                                     Int?
  Name                                                                         String?
  ShortName                                                                    String?
  Info                                                                         String?
  IncludeEntitiesTypeNumber                                                    Int?
  IncludeCreditScoresTypeNumber                                                Int?
  IncludeAccountGroupsTypeNumber                                               Int?
  IncludeAccountsTypeNumber                                                    Int?
  IncludeFlagsTypeNumber                                                       Int?
  IncludePayeesTypeNumber                                                      Int?
  IncludeTransactionTypesTypeNumber                                            Int?
  IncludeCategoriesTypeNumber                                                  Int?
  IncludeTagsTypeNumber                                                        Int?
  IncludeSecurityTypesTypeNumber                                               Int?
  IncludeSecuritiesTypeNumber                                                  Int?
  IncludeSecurityGroupsTypeNumber                                              Int?
  IncludeSecurityGoalsTypeNumber                                               Int?
  IncludeSecurityAssetClassesTypeNumber                                        Int?
  IncludeSecuritySectorsTypeNumber                                             Int?
  IncludeSecurityIndustriesTypeNumber                                          Int?
  IncludeSecurityExchangesTypeNumber                                           Int?
  IncludeSecurityFundCategoriesTypeNumber                                      Int?
  IncludeSecurityFundFamiliesTypeNumber                                        Int?
  IncludeSecurityCustomLabelsTypeNumber                                        Int?
  IncludeInvestmentPortfoliosTypeNumber                                        Int?
  IncludeScheduledTransactionsTypeNumber                                       Int?
  IncludeOtherEntityListing                                                    Int?
  IncludeOtherCreditScoreListing                                               Int?
  IncludeOtherAccountGroupListing                                              Int?
  IncludeOtherAccountListing                                                   Int?
  IncludeOtherFlagListing                                                      Int?
  IncludeOtherPayeeListing                                                     Int?
  IncludeOtherTransactionTypeListing                                           Int?
  IncludeOtherCategoryListing                                                  Int?
  IncludeOtherIncomeCategoryListing                                            Int?
  IncludeOtherExpensesCategoryListing                                          Int?
  IncludeOtherTagListing                                                       Int?
  IncludeOtherSecurityTypeListing                                              Int?
  IncludeOtherSecurityListing                                                  Int?
  IncludeOtherSecurityGroupListing                                             Int?
  IncludeOtherSecurityGoalListing                                              Int?
  IncludeOtherSecurityAssetClassListing                                        Int?
  IncludeOtherSecuritySectorListing                                            Int?
  IncludeOtherSecurityIndustryListing                                          Int?
  IncludeOtherSecurityExchangeListing                                          Int?
  IncludeOtherSecurityFundCategoryListing                                      Int?
  IncludeOtherSecurityFundFamilyListing                                        Int?
  IncludeOtherSecurityCustomLabelListing                                       Int?
  IncludeOtherInvestmentPortfolioListing                                       Int?
  IncludeNoEntityListing                                                       Int?
  IncludeNoCreditScoreListing                                                  Int?
  IncludeNoAccountGroupListing                                                 Int?
  IncludeNoAccountListing                                                      Int?
  IncludeNoFlagListing                                                         Int?
  IncludeNoPayeeListing                                                        Int?
  IncludeNoTransactionTypeListing                                              Int?
  IncludeNoCategoryListing                                                     Int?
  IncludeNoIncomeCategoryListing                                               Int?
  IncludeNoExpensesCategoryListing                                             Int?
  IncludeNoTagListing                                                          Int?
  IncludeNoSecurityTypeListing                                                 Int?
  IncludeNoSecurityListing                                                     Int?
  IncludeNoSecurityGroupListing                                                Int?
  IncludeNoSecurityGoalListing                                                 Int?
  IncludeNoSecurityAssetClassListing                                           Int?
  IncludeNoSecuritySectorListing                                               Int?
  IncludeNoSecurityIndustryListing                                             Int?
  IncludeNoSecurityExchangeListing                                             Int?
  IncludeNoSecurityFundCategoryListing                                         Int?
  IncludeNoSecurityFundFamilyListing                                           Int?
  IncludeNoSecurityCustomLabelListing                                          Int?
  IncludeNoInvestmentPortfolioListing                                          Int?
  IncludeDefaultPortfolioListing                                               Int?
  IncludeBalanceAdjustmentsTypeNumber                                          Int?
  IncludeTransfersTypeNumber                                                   Int?
  IncludeTransactionOriginTypeNumber                                           Int?
  IncludeTransactionAmountTypeNumber                                           Int?
  IncludeTransactionStatusTypeNumber                                           Int?
  IncludeItemsPastTodayTypeNumber                                              Int?
  IncludeTotalAmountTypeNumber                                                 Int?
  IncludeTotal                                                                 Int?
  IncludeIncomeTotal                                                           Int?
  IncludeExpensesTotal                                                         Int?
  OverallParametersCombinationTypeNumber                                       Int?
  ObjectMatchesCombinationTypeNumber                                           Int?
  ScalingFactor                                                                Float?
  FontName                                                                     String?
  FontSize                                                                     Float?
  RowHeight                                                                    Float?
  HeadingColorString                                                           String?
  AlternatingRowColorString                                                    String?
  ShowAlternatingRowColor                                                      Int?
  ConstrainGraphXAxisToZero                                                    Int?
  ConstrainGraphYAxisToZero                                                    Int?
  FlipGraphDefaultAxis                                                         Int?
  NumberOfRowsValuesCanExpandInto                                              Int?
  ShowItemsWithShortNames                                                      Int?
  ShowItemsWithoutValues                                                       Int?
  ShowRowInfoAcrossTwoLines                                                    Int?
  ShowAmountsWithoutDecimals                                                   Int?
  ShowInvestmentPositionDetails                                                Int?
  ShowTransactionSplitDetails                                                  Int?
  ShowOtherDetails                                                             Int?
  IncludeColumnsTypeNumber                                                     Int?
  ItemSortingTypeNumber                                                        Int?
  TransactionSortingTypeNumber                                                 Int?
  SecuritySortingTypeNumber                                                    Int?
  InvestmentPositionSortingTypeNumber                                          Int?
  MiscValues                                                                   Bytes?
  ExchangeRateSets                                                             ExchangeRateSets?               @relation(fields: [ExchangeRateSetID_FK], references: [ExchangeRateSetID_PK])
  ReportColumnDetails_ReportColumnDetailsToReports_ReportColumnDetailsID_UK_FK ReportColumnDetails?            @relation("ReportColumnDetailsToReports_ReportColumnDetailsID_UK_FK", fields: [ReportColumnDetailsID_UK_FK], references: [ReportColumnDetailsID_PK])
  ReportGroups                                                                 ReportGroups?                   @relation(fields: [ReportGroupID_FK], references: [ReportGroupID_PK])
  Attachments                                                                  Attachments[]
  Notes                                                                        Notes[]
  ObjectMatches                                                                ObjectMatches[]
  ReportColumnDetails_ReportColumnDetails_ReportID_NN_UK_FKToReports           ReportColumnDetails?            @relation("ReportColumnDetails_ReportID_NN_UK_FKToReports")
  ReportForecastDetails                                                        ReportForecastDetails[]
  ReportGoalDetails                                                            ReportGoalDetails[]
  ReportsAccountGroups                                                         ReportsAccountGroups[]
  ReportsAccounts                                                              ReportsAccounts[]
  ReportsCategories                                                            ReportsCategories[]
  ReportsCreditScores                                                          ReportsCreditScores[]
  ReportsEntities                                                              ReportsEntities[]
  ReportsFlags                                                                 ReportsFlags[]
  ReportsInvestmentPortfolios                                                  ReportsInvestmentPortfolios[]
  ReportsPayees                                                                ReportsPayees[]
  ReportsScheduledTransactions                                                 ReportsScheduledTransactions[]
  ReportsSecurities                                                            ReportsSecurities[]
  ReportsSecurityAssetClasses                                                  ReportsSecurityAssetClasses[]
  ReportsSecurityCustomLabels                                                  ReportsSecurityCustomLabels[]
  ReportsSecurityExchanges                                                     ReportsSecurityExchanges[]
  ReportsSecurityFundCategories                                                ReportsSecurityFundCategories[]
  ReportsSecurityFundFamilies                                                  ReportsSecurityFundFamilies[]
  ReportsSecurityGoals                                                         ReportsSecurityGoals[]
  ReportsSecurityGroups                                                        ReportsSecurityGroups[]
  ReportsSecurityIndustries                                                    ReportsSecurityIndustries[]
  ReportsSecuritySectors                                                       ReportsSecuritySectors[]
  ReportsSecurityTypes                                                         ReportsSecurityTypes[]
  ReportsTags                                                                  ReportsTags[]
  ReportsTransactionTypes                                                      ReportsTransactionTypes[]
  ReportsTransactions                                                          ReportsTransactions[]
}

model ReportsAccountGroups {
  ReportID_NN_FK       String
  AccountGroupID_NN_FK String
  AccountGroups        AccountGroups @relation(fields: [AccountGroupID_NN_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Reports              Reports       @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, AccountGroupID_NN_FK])
}

model ReportsAccounts {
  ReportID_NN_FK  String
  AccountID_NN_FK String
  Accounts        Accounts @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Reports         Reports  @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, AccountID_NN_FK])
}

model ReportsCategories {
  ReportID_NN_FK   String
  CategoryID_NN_FK String
  Categories       Categories @relation(fields: [CategoryID_NN_FK], references: [CategoryID_PK], onDelete: Cascade)
  Reports          Reports    @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, CategoryID_NN_FK])
}

model ReportsCreditScores {
  ReportID_NN_FK      String
  CreditScoreID_NN_FK String
  CreditScores        CreditScores @relation(fields: [CreditScoreID_NN_FK], references: [CreditScoreID_PK], onDelete: Cascade)
  Reports             Reports      @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, CreditScoreID_NN_FK])
}

model ReportsEntities {
  ReportID_NN_FK String
  EntityID_NN_FK String
  Entities       Entities @relation(fields: [EntityID_NN_FK], references: [EntityID_PK], onDelete: Cascade)
  Reports        Reports  @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, EntityID_NN_FK])
}

model ReportsFlags {
  ReportID_NN_FK String
  FlagID_NN_FK   String
  Flags          Flags   @relation(fields: [FlagID_NN_FK], references: [FlagID_PK], onDelete: Cascade)
  Reports        Reports @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, FlagID_NN_FK])
}

model ReportsInvestmentPortfolios {
  ReportID_NN_FK              String
  InvestmentPortfolioID_NN_FK String
  InvestmentPortfolios        InvestmentPortfolios @relation(fields: [InvestmentPortfolioID_NN_FK], references: [InvestmentPortfolioID_PK], onDelete: Cascade)
  Reports                     Reports              @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, InvestmentPortfolioID_NN_FK])
}

model ReportsPayees {
  ReportID_NN_FK String
  PayeeID_NN_FK  String
  Payees         Payees  @relation(fields: [PayeeID_NN_FK], references: [PayeeID_PK], onDelete: Cascade)
  Reports        Reports @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, PayeeID_NN_FK])
}

model ReportsScheduledTransactions {
  ReportID_NN_FK               String
  ScheduledTransactionID_NN_FK String
  Reports                      Reports               @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  ScheduledTransactions        ScheduledTransactions @relation(fields: [ScheduledTransactionID_NN_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, ScheduledTransactionID_NN_FK])
}

model ReportsSecurities {
  ReportID_NN_FK   String
  SecurityID_NN_FK String
  Reports          Reports    @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  Securities       Securities @relation(fields: [SecurityID_NN_FK], references: [SecurityID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityID_NN_FK])
}

model ReportsSecurityAssetClasses {
  ReportID_NN_FK             String
  SecurityAssetClassID_NN_FK String
  Reports                    Reports              @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityAssetClasses       SecurityAssetClasses @relation(fields: [SecurityAssetClassID_NN_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityAssetClassID_NN_FK])
}

model ReportsSecurityCustomLabels {
  ReportID_NN_FK              String
  SecurityCustomLabelID_NN_FK String
  Reports                     Reports              @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityCustomLabels        SecurityCustomLabels @relation(fields: [SecurityCustomLabelID_NN_FK], references: [SecurityCustomLabelID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityCustomLabelID_NN_FK])
}

model ReportsSecurityExchanges {
  ReportID_NN_FK           String
  SecurityExchangeID_NN_FK String
  Reports                  Reports           @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityExchanges        SecurityExchanges @relation(fields: [SecurityExchangeID_NN_FK], references: [SecurityExchangeID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityExchangeID_NN_FK])
}

model ReportsSecurityFundCategories {
  ReportID_NN_FK               String
  SecurityFundCategoryID_NN_FK String
  Reports                      Reports        @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  fundCategories               fundCategories @relation(fields: [SecurityFundCategoryID_NN_FK], references: [SecurityFundCategoryID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityFundCategoryID_NN_FK])
}

model ReportsSecurityFundFamilies {
  ReportID_NN_FK             String
  SecurityFundFamilyID_NN_FK String
  Reports                    Reports              @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityFundFamilies       SecurityFundFamilies @relation(fields: [SecurityFundFamilyID_NN_FK], references: [SecurityFundFamilyID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityFundFamilyID_NN_FK])
}

model ReportsSecurityGoals {
  ReportID_NN_FK       String
  SecurityGoalID_NN_FK String
  Reports              Reports       @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityGoals        SecurityGoals @relation(fields: [SecurityGoalID_NN_FK], references: [SecurityGoalID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityGoalID_NN_FK])
}

model ReportsSecurityGroups {
  ReportID_NN_FK        String
  SecurityGroupID_NN_FK String
  Reports               Reports        @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityGroups        SecurityGroups @relation(fields: [SecurityGroupID_NN_FK], references: [SecurityGroupID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityGroupID_NN_FK])
}

model ReportsSecurityIndustries {
  ReportID_NN_FK           String
  SecurityIndustryID_NN_FK String
  Reports                  Reports            @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityIndustries       SecurityIndustries @relation(fields: [SecurityIndustryID_NN_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityIndustryID_NN_FK])
}

model ReportsSecuritySectors {
  ReportID_NN_FK         String
  SecuritySectorID_NN_FK String
  Reports                Reports         @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecuritySectors        SecuritySectors @relation(fields: [SecuritySectorID_NN_FK], references: [SecuritySectorID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecuritySectorID_NN_FK])
}

model ReportsSecurityTypes {
  ReportID_NN_FK       String
  SecurityTypeID_NN_FK String
  Reports              Reports       @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  SecurityTypes        SecurityTypes @relation(fields: [SecurityTypeID_NN_FK], references: [SecurityTypeID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, SecurityTypeID_NN_FK])
}

model ReportsTags {
  ReportID_NN_FK String
  TagID_NN_FK    String
  Reports        Reports @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  Tags           Tags    @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, TagID_NN_FK])
}

model ReportsTransactionTypes {
  ReportID_NN_FK          String
  TransactionTypeID_NN_FK String
  Reports                 Reports          @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  TransactionTypes        TransactionTypes @relation(fields: [TransactionTypeID_NN_FK], references: [TransactionTypeID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, TransactionTypeID_NN_FK])
}

model ReportsTransactions {
  ReportID_NN_FK      String
  TransactionID_NN_FK String
  Reports             Reports      @relation(fields: [ReportID_NN_FK], references: [ReportID_PK], onDelete: Cascade)
  Transactions        Transactions @relation(fields: [TransactionID_NN_FK], references: [TransactionID_PK], onDelete: Cascade)

  @@id([ReportID_NN_FK, TransactionID_NN_FK])
}

model ScheduledTransactions {
  ScheduledTransactionID_PK                                                                                             String                         @id
  ParentID_FK                                                                                                           String?
  Position                                                                                                              Int?
  LoanAccountDetailsID_UK_FK                                                                                            String?                        @unique(map: "sqlite_autoindex_ScheduledTransactions_2")
  GoalAccountDetailsID_UK_FK                                                                                            String?                        @unique(map: "sqlite_autoindex_ScheduledTransactions_3")
  AccountID_FK                                                                                                          String?
  AccountUserID_FK                                                                                                      String?
  FlagID_FK                                                                                                             String?
  PayeeID_FK                                                                                                            String?
  TransactionTypeID_FK                                                                                                  String?
  CategoryID_FK                                                                                                         String?
  InvestmentTransactionDetailsID_UK_FK                                                                                  String?                        @unique(map: "sqlite_autoindex_ScheduledTransactions_4")
  LoanTransactionDetailsID_UK_FK                                                                                        String?                        @unique(map: "sqlite_autoindex_ScheduledTransactions_5")
  TypeNumber                                                                                                            Int?
  Name                                                                                                                  String?
  ShortName                                                                                                             String?
  Info                                                                                                                  String?
  CreationDate                                                                                                          Float?
  ModifiedDate                                                                                                          Float?
  Active                                                                                                                Int?
  DateIntervalTypeNumber                                                                                                Int?
  StartDate                                                                                                             Float?
  EndDate                                                                                                               Float?
  LastDate                                                                                                              Float?
  DateTypeNumber                                                                                                        Int?
  PostTypeNumber                                                                                                        Int?
  PostToPendingDateTypeNumber                                                                                           Int?
  DaysInAdvanceToPostToPending                                                                                          Int?
  PostToAccountDateTypeNumber                                                                                           Int?
  DaysInAdvanceToPostToAccount                                                                                          Int?
  PostToAccountStatusNumber                                                                                             Int?
  IncludeInCalendar                                                                                                     Int?
  EventCalendarIdentifier                                                                                               String?
  EventCalendarItemExternalIdentifier                                                                                   String?
  EventAlarmTypeNumber                                                                                                  Int?
  IncludeInReminders                                                                                                    Int?
  RemindersCalendarIdentifier                                                                                           String?
  ReminderCalendarItemExternalIdentifier                                                                                String?
  ReminderAlarmTypeNumber                                                                                               Int?
  Memo                                                                                                                  String?
  ApplyNextCheckNumber                                                                                                  Int?
  CheckNumber                                                                                                           String?
  TransactionNumber                                                                                                     String?
  AmountTypeNumber                                                                                                      Int?
  Amount                                                                                                                Float?
  PercentAmount                                                                                                         Float?
  MiscValues                                                                                                            Bytes?
  Accounts                                                                                                              Accounts?                      @relation(fields: [AccountID_FK], references: [AccountID_PK])
  Entities                                                                                                              Entities?                      @relation(fields: [AccountUserID_FK], references: [EntityID_PK])
  Categories                                                                                                            Categories?                    @relation(fields: [CategoryID_FK], references: [CategoryID_PK])
  Flags                                                                                                                 Flags?                         @relation(fields: [FlagID_FK], references: [FlagID_PK])
  GoalAccountDetails_GoalAccountDetailsToScheduledTransactions_GoalAccountDetailsID_UK_FK                               GoalAccountDetails?            @relation("GoalAccountDetailsToScheduledTransactions_GoalAccountDetailsID_UK_FK", fields: [GoalAccountDetailsID_UK_FK], references: [GoalAccountDetailsID_PK], onDelete: Cascade)
  InvestmentTransactionDetails_InvestmentTransactionDetailsToScheduledTransactions_InvestmentTransactionDetailsID_UK_FK InvestmentTransactionDetails?  @relation("InvestmentTransactionDetailsToScheduledTransactions_InvestmentTransactionDetailsID_UK_FK", fields: [InvestmentTransactionDetailsID_UK_FK], references: [InvestmentTransactionDetailsID_PK])
  LoanAccountDetails_LoanAccountDetailsToScheduledTransactions_LoanAccountDetailsID_UK_FK                               LoanAccountDetails?            @relation("LoanAccountDetailsToScheduledTransactions_LoanAccountDetailsID_UK_FK", fields: [LoanAccountDetailsID_UK_FK], references: [LoanAccountDetailsID_PK], onDelete: Cascade)
  LoanTransactionDetails_LoanTransactionDetailsToScheduledTransactions_LoanTransactionDetailsID_UK_FK                   LoanTransactionDetails?        @relation("LoanTransactionDetailsToScheduledTransactions_LoanTransactionDetailsID_UK_FK", fields: [LoanTransactionDetailsID_UK_FK], references: [LoanTransactionDetailsID_PK])
  ScheduledTransactions                                                                                                 ScheduledTransactions?         @relation("ScheduledTransactionsToScheduledTransactions_ParentID_FK", fields: [ParentID_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  Payees                                                                                                                Payees?                        @relation(fields: [PayeeID_FK], references: [PayeeID_PK])
  TransactionTypes                                                                                                      TransactionTypes?              @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK])
  Attachments                                                                                                           Attachments[]
  BudgetsScheduledTransactions                                                                                          BudgetsScheduledTransactions[]
  GoalAccountDetails_GoalAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions                             GoalAccountDetails?            @relation("GoalAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions")
  InvestmentTransactionDetails_InvestmentTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions         InvestmentTransactionDetails?  @relation("InvestmentTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions")
  LoanAccountDetails_LoanAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions                             LoanAccountDetails?            @relation("LoanAccountDetails_ScheduledTransactionID_UK_FKToScheduledTransactions")
  LoanTransactionDetails_LoanTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions                     LoanTransactionDetails?        @relation("LoanTransactionDetails_ScheduledTransactionID_UK_FKToScheduledTransactions")
  Notes                                                                                                                 Notes[]
  ReportsScheduledTransactions                                                                                          ReportsScheduledTransactions[]
  other_ScheduledTransactions                                                                                           ScheduledTransactions[]        @relation("ScheduledTransactionsToScheduledTransactions_ParentID_FK")
  ScheduledTransactionsTags                                                                                             ScheduledTransactionsTags[]
  Transactions                                                                                                          Transactions[]
}

model ScheduledTransactionsTags {
  ScheduledTransactionID_NN_FK String
  TagID_NN_FK                  String
  ScheduledTransactions        ScheduledTransactions @relation(fields: [ScheduledTransactionID_NN_FK], references: [ScheduledTransactionID_PK], onDelete: Cascade)
  Tags                         Tags                  @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)

  @@id([ScheduledTransactionID_NN_FK, TagID_NN_FK])
}

model Securities {
  SecurityID_PK                                      String                           @id
  SecurityTypeID_NN_FK                               String
  UnderlyingSecurityID_FK                            String?
  AccountID_UK_FK                                    String?                          @unique(map: "sqlite_autoindex_Securities_2")
  SecurityGroupID_FK                                 String?
  SecurityGoalID_FK                                  String?
  SecurityExchangeID_FK                              String?
  SecurityFundCategoryID_FK                          String?
  SecurityFundFamilyID_FK                            String?
  SecurityCustomLabelID_FK                           String?
  WebsiteID_UK_FK                                    String?                          @unique(map: "sqlite_autoindex_Securities_3")
  Position                                           Int?
  BehaviorTypeNumber                                 Int?
  CurrencyCode                                       String?
  IncludeInLists                                     Int?
  IncludeInReports                                   Int?
  IncludeInWatchList                                 Int?
  Favorite                                           Int?
  Name                                               String?
  ShortName                                          String?
  Info                                               String?
  ColorString                                        String?
  AlternateColorString                               String?
  TintColorString                                    String?
  AlternateTintColorString                           String?
  ImageData                                          Bytes?
  AlternateImageData                                 Bytes?
  IdentifierTypeNumber                               Int?
  Identifier                                         String?
  Symbol                                             String?
  DataSourceTypeNumber                               Int?
  DataSourceIdentifier                               String?
  YahooSymbol                                        String?
  GoogleSymbol                                       String?
  MorningstarSymbol                                  String?
  OtherWebsite1Symbol                                String?
  OtherWebsite2Symbol                                String?
  TaxFree                                            Int?
  DefaultLotTrackingTypeNumber                       Int?
  MinimumFractionDigits                              Int?
  MaximumFractionDigits                              Int?
  UnitPrice                                          Float?
  UnitPriceAsOfDate                                  Float?
  PreviousUnitPrice                                  Float?
  ChangeInUnitPrice                                  Float?
  PercentChangeInUnitPrice                           Float?
  LowAlertUnitPricePoint                             Float?
  HighAlertUnitPricePoint                            Float?
  ImportUnitPrice                                    Int?
  ImportOtherInfo                                    Int?
  ImportHistoricalPrices                             Int?
  DownloadUnitPrice                                  Int?
  DownloadOtherInfo                                  Int?
  DownloadHistoricalPrices                           Int?
  LastUnitPriceDownloadDate                          Float?
  LastOtherInfoDownloadDate                          Float?
  LastHistoricalPriceDownloadDate                    Float?
  DateOfMostRecentDownloadedHistoricalQuote          Float?
  AdjustedCloseOfMostRecentDownloadedHistoricalQuote Float?
  Open                                               Float?
  Bid                                                Float?
  BidSize                                            Float?
  Ask                                                Float?
  AskSize                                            Float?
  DaysLow                                            Float?
  DaysHigh                                           Float?
  FiftyTwoWeekLow                                    Float?
  FiftyTwoWeekHigh                                   Float?
  Volume                                             Float?
  AverageVolume                                      Float?
  MarketCapTypeNumber                                Int?
  MarketCap                                          Float?
  Dividend                                           Float?
  DividendYield                                      Float?
  PriceEarningsRatio                                 Float?
  OneYearForwardPriceEarningsRatio                   Float?
  EarningsPerShare                                   Float?
  OneYearTargetEstimate                              Float?
  PriceShareRatio                                    Float?
  PriceBookRatio                                     Float?
  PegFiveYearExpected                                Float?
  TotalExpenseRatio                                  Float?
  LongTermDebtEquityRatio                            Float?
  PriceFreeCashFlowRatio                             Float?
  NetProfitMargin                                    Float?
  ReturnOnEquity                                     Float?
  YearToDateReturn                                   Float?
  ThreeYearAverageReturn                             Float?
  FiveYearAverageReturn                              Float?
  Beta1Year                                          Float?
  Beta2Year                                          Float?
  Beta3Year                                          Float?
  Beta5Year                                          Float?
  FiftyDayMovingAverage                              Float?
  TwoHundredDayMovingAverage                         Float?
  ExpectedReturn                                     Float?
  StandardDeviation                                  Float?
  InceptionDate                                      Float?
  NetAssets                                          Float?
  NetAssetValue                                      Float?
  TurnoverRatio                                      Float?
  BackLoad                                           Float?
  FundRatingTypeNumber                               Int?
  FundRiskRatingTypeNumber                           Int?
  RankInCategory                                     Float?
  PercentRankInCategory                              Float?
  IssueDate                                          Float?
  MaturityDate                                       Float?
  ParValue                                           Float?
  BondIssuerTypeNumber                               Int?
  BondPayoutTypeNumber                               Int?
  CouponRate                                         Float?
  CouponFrequencyTypeNumber                          Int?
  CallDate                                           Float?
  CallTypeNumber                                     Int?
  CallUnitPrice                                      Float?
  CurrentYield                                       Float?
  YieldToCall                                        Float?
  YieldToMaturity                                    Float?
  BondRatingTypeNumber                               Int?
  FloatingRateTypeNumber                             Int?
  FloatingRateSpread                                 Float?
  OriginalPrincipalAmount                            Float?
  InflationIndexRatio                                Float?
  CurrentPoolFactor                                  Float?
  OptionTypeNumber                                   Int?
  OptionStyleNumber                                  Int?
  SharesPerContract                                  Float?
  ExpirationDate                                     Float?
  Strike                                             Float?
  ContractLow                                        Float?
  ContractHigh                                       Float?
  OpenInterest                                       Float?
  MiscValues                                         Bytes?
  Accounts_AccountsToSecurities_AccountID_UK_FK      Accounts?                        @relation("AccountsToSecurities_AccountID_UK_FK", fields: [AccountID_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  SecurityCustomLabels                               SecurityCustomLabels?            @relation(fields: [SecurityCustomLabelID_FK], references: [SecurityCustomLabelID_PK])
  SecurityExchanges                                  SecurityExchanges?               @relation(fields: [SecurityExchangeID_FK], references: [SecurityExchangeID_PK])
  fundCategories                                     fundCategories?                  @relation(fields: [SecurityFundCategoryID_FK], references: [SecurityFundCategoryID_PK])
  SecurityFundFamilies                               SecurityFundFamilies?            @relation(fields: [SecurityFundFamilyID_FK], references: [SecurityFundFamilyID_PK])
  SecurityGoals                                      SecurityGoals?                   @relation(fields: [SecurityGoalID_FK], references: [SecurityGoalID_PK])
  SecurityGroups                                     SecurityGroups?                  @relation(fields: [SecurityGroupID_FK], references: [SecurityGroupID_PK])
  SecurityTypes                                      SecurityTypes                    @relation(fields: [SecurityTypeID_NN_FK], references: [SecurityTypeID_PK], onDelete: Cascade)
  Securities                                         Securities?                      @relation("SecuritiesToSecurities_UnderlyingSecurityID_FK", fields: [UnderlyingSecurityID_FK], references: [SecurityID_PK])
  Websites_Securities_WebsiteID_UK_FKToWebsites      Websites?                        @relation("Securities_WebsiteID_UK_FKToWebsites", fields: [WebsiteID_UK_FK], references: [WebsiteID_PK])
  Accounts_Accounts_SecurityID_UK_FKToSecurities     Accounts?                        @relation("Accounts_SecurityID_UK_FKToSecurities")
  Attachments                                        Attachments[]
  HistoricalPrices                                   HistoricalPrices[]
  InvestmentAccountDetails                           InvestmentAccountDetails[]
  InvestmentPortfoliosSecurities                     InvestmentPortfoliosSecurities[]
  InvestmentTransactionDetails                       InvestmentTransactionDetails[]
  Notes                                              Notes[]
  ReportForecastDetails                              ReportForecastDetails[]
  ReportGoalDetails                                  ReportGoalDetails[]
  ReportsSecurities                                  ReportsSecurities[]
  other_Securities                                   Securities[]                     @relation("SecuritiesToSecurities_UnderlyingSecurityID_FK")
  SecuritiesAssetClasses                             SecuritiesAssetClasses[]
  SecuritiesIndustries                               SecuritiesIndustries[]
  Websites_SecuritiesToWebsites_SecurityID_UK_FK     Websites?                        @relation("SecuritiesToWebsites_SecurityID_UK_FK")
}

model SecuritiesAssetClasses {
  SecurityID_NN_FK           String
  SecurityAssetClassID_NN_FK String
  Percent                    Float?
  SecurityAssetClasses       SecurityAssetClasses @relation(fields: [SecurityAssetClassID_NN_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  Securities                 Securities           @relation(fields: [SecurityID_NN_FK], references: [SecurityID_PK], onDelete: Cascade)

  @@id([SecurityID_NN_FK, SecurityAssetClassID_NN_FK])
}

model SecuritiesIndustries {
  SecurityID_NN_FK         String
  SecurityIndustryID_NN_FK String
  Percent                  Float?
  Securities               Securities         @relation(fields: [SecurityID_NN_FK], references: [SecurityID_PK], onDelete: Cascade)
  SecurityIndustries       SecurityIndustries @relation(fields: [SecurityIndustryID_NN_FK], references: [SecurityIndustryID_PK], onDelete: Cascade)

  @@id([SecurityID_NN_FK, SecurityIndustryID_NN_FK])
}

model SecurityAssetClasses {
  SecurityAssetClassID_PK                  String                                     @id
  ParentID_FK                              String?
  Position                                 Int?
  TypeNumber                               Int?
  IncludeInLists                           Int?
  IncludeInReports                         Int?
  Favorite                                 Int?
  Name                                     String?
  ShortName                                String?
  Info                                     String?
  ColorString                              String?
  AlternateColorString                     String?
  TintColorString                          String?
  AlternateTintColorString                 String?
  ImageData                                Bytes?
  AlternateImageData                       Bytes?
  SecurityAssetClasses                     SecurityAssetClasses?                      @relation("SecurityAssetClassesToSecurityAssetClasses_ParentID_FK", fields: [ParentID_FK], references: [SecurityAssetClassID_PK], onDelete: Cascade)
  Attachments                              Attachments[]
  InvestmentPortfoliosSecurityAssetClasses InvestmentPortfoliosSecurityAssetClasses[]
  Notes                                    Notes[]
  ReportForecastDetails                    ReportForecastDetails[]
  ReportGoalDetails                        ReportGoalDetails[]
  ReportsSecurityAssetClasses              ReportsSecurityAssetClasses[]
  SecuritiesAssetClasses                   SecuritiesAssetClasses[]
  other_SecurityAssetClasses               SecurityAssetClasses[]                     @relation("SecurityAssetClassesToSecurityAssetClasses_ParentID_FK")
}

model SecurityCustomLabels {
  SecurityCustomLabelID_PK                 String                                     @id
  ParentID_FK                              String?
  Position                                 Int?
  TypeNumber                               Int?
  IncludeInLists                           Int?
  IncludeInReports                         Int?
  Favorite                                 Int?
  Name                                     String?
  ShortName                                String?
  Info                                     String?
  ColorString                              String?
  AlternateColorString                     String?
  TintColorString                          String?
  AlternateTintColorString                 String?
  ImageData                                Bytes?
  AlternateImageData                       Bytes?
  SecurityCustomLabels                     SecurityCustomLabels?                      @relation("SecurityCustomLabelsToSecurityCustomLabels_ParentID_FK", fields: [ParentID_FK], references: [SecurityCustomLabelID_PK], onDelete: Cascade)
  Attachments                              Attachments[]
  InvestmentPortfoliosSecurityCustomLabels InvestmentPortfoliosSecurityCustomLabels[]
  Notes                                    Notes[]
  ReportForecastDetails                    ReportForecastDetails[]
  ReportGoalDetails                        ReportGoalDetails[]
  ReportsSecurityCustomLabels              ReportsSecurityCustomLabels[]
  Securities                               Securities[]
  other_SecurityCustomLabels               SecurityCustomLabels[]                     @relation("SecurityCustomLabelsToSecurityCustomLabels_ParentID_FK")
}

model SecurityExchanges {
  SecurityExchangeID_PK                 String                                  @id
  Position                              Int?
  TypeNumber                            Int?
  CurrencyCode                          String?
  IncludeInLists                        Int?
  IncludeInReports                      Int?
  Favorite                              Int?
  Name                                  String?
  ShortName                             String?
  Info                                  String?
  ColorString                           String?
  AlternateColorString                  String?
  TintColorString                       String?
  AlternateTintColorString              String?
  ImageData                             Bytes?
  AlternateImageData                    Bytes?
  CountryCode                           String?
  TimeZoneName                          String?
  OpeningBellHour                       Int?
  OpeningBellMinute                     Int?
  ClosingBellHour                       Int?
  ClosingBellMinute                     Int?
  Attachments                           Attachments[]
  InvestmentPortfoliosSecurityExchanges InvestmentPortfoliosSecurityExchanges[]
  Notes                                 Notes[]
  ReportForecastDetails                 ReportForecastDetails[]
  ReportGoalDetails                     ReportGoalDetails[]
  ReportsSecurityExchanges              ReportsSecurityExchanges[]
  Securities                            Securities[]
}

model SecurityFundFamilies {
  SecurityFundFamilyID_PK                  String                                     @id
  Position                                 Int?
  TypeNumber                               Int?
  IncludeInLists                           Int?
  IncludeInReports                         Int?
  Favorite                                 Int?
  Name                                     String?
  ShortName                                String?
  Info                                     String?
  ColorString                              String?
  AlternateColorString                     String?
  TintColorString                          String?
  AlternateTintColorString                 String?
  ImageData                                Bytes?
  AlternateImageData                       Bytes?
  Attachments                              Attachments[]
  InvestmentPortfoliosSecurityFundFamilies InvestmentPortfoliosSecurityFundFamilies[]
  Notes                                    Notes[]
  ReportForecastDetails                    ReportForecastDetails[]
  ReportGoalDetails                        ReportGoalDetails[]
  ReportsSecurityFundFamilies              ReportsSecurityFundFamilies[]
  Securities                               Securities[]
}

model SecurityGoals {
  SecurityGoalID_PK                 String                              @id
  ParentID_FK                       String?
  Position                          Int?
  TypeNumber                        Int?
  IncludeInLists                    Int?
  IncludeInReports                  Int?
  Favorite                          Int?
  Name                              String?
  ShortName                         String?
  Info                              String?
  ColorString                       String?
  AlternateColorString              String?
  TintColorString                   String?
  AlternateTintColorString          String?
  ImageData                         Bytes?
  AlternateImageData                Bytes?
  SecurityGoals                     SecurityGoals?                      @relation("SecurityGoalsToSecurityGoals_ParentID_FK", fields: [ParentID_FK], references: [SecurityGoalID_PK], onDelete: Cascade)
  Attachments                       Attachments[]
  InvestmentPortfoliosSecurityGoals InvestmentPortfoliosSecurityGoals[]
  Notes                             Notes[]
  ReportForecastDetails             ReportForecastDetails[]
  ReportGoalDetails                 ReportGoalDetails[]
  ReportsSecurityGoals              ReportsSecurityGoals[]
  Securities                        Securities[]
  other_SecurityGoals               SecurityGoals[]                     @relation("SecurityGoalsToSecurityGoals_ParentID_FK")
}

model SecurityGroups {
  SecurityGroupID_PK                 String                               @id
  ParentID_FK                        String?
  Position                           Int?
  TypeNumber                         Int?
  IncludeInLists                     Int?
  IncludeInReports                   Int?
  Favorite                           Int?
  Name                               String?
  ShortName                          String?
  Info                               String?
  ColorString                        String?
  AlternateColorString               String?
  TintColorString                    String?
  AlternateTintColorString           String?
  ImageData                          Bytes?
  AlternateImageData                 Bytes?
  SecurityGroups                     SecurityGroups?                      @relation("SecurityGroupsToSecurityGroups_ParentID_FK", fields: [ParentID_FK], references: [SecurityGroupID_PK], onDelete: Cascade)
  Attachments                        Attachments[]
  InvestmentPortfoliosSecurityGroups InvestmentPortfoliosSecurityGroups[]
  Notes                              Notes[]
  ReportForecastDetails              ReportForecastDetails[]
  ReportGoalDetails                  ReportGoalDetails[]
  ReportsSecurityGroups              ReportsSecurityGroups[]
  Securities                         Securities[]
  other_SecurityGroups               SecurityGroups[]                     @relation("SecurityGroupsToSecurityGroups_ParentID_FK")
}

model SecurityIndustries {
  SecurityIndustryID_PK                  String                                   @id
  SecuritySectorID_NN_FK                 String
  Position                               Int?
  TypeNumber                             Int?
  IncludeInLists                         Int?
  IncludeInReports                       Int?
  Favorite                               Int?
  Name                                   String?
  ShortName                              String?
  Info                                   String?
  ColorString                            String?
  AlternateColorString                   String?
  TintColorString                        String?
  AlternateTintColorString               String?
  ImageData                              Bytes?
  AlternateImageData                     Bytes?
  YahooSymbol                            String?
  OtherWebsite1Symbol                    String?
  OtherWebsite2Symbol                    String?
  PercentChangeInUnitPrice               Float?
  MarketCap                              Float?
  DividendYield                          Float?
  PriceEarningsRatio                     Float?
  PriceBookRatio                         Float?
  LongTermDebtEquityRatio                Float?
  PriceFreeCashFlowRatio                 Float?
  NetProfitMargin                        Float?
  ReturnOnEquity                         Float?
  SecuritySectors                        SecuritySectors                          @relation(fields: [SecuritySectorID_NN_FK], references: [SecuritySectorID_PK], onDelete: Cascade)
  Attachments                            Attachments[]
  InvestmentPortfoliosSecurityIndustries InvestmentPortfoliosSecurityIndustries[]
  Notes                                  Notes[]
  ReportForecastDetails                  ReportForecastDetails[]
  ReportGoalDetails                      ReportGoalDetails[]
  ReportsSecurityIndustries              ReportsSecurityIndustries[]
  SecuritiesIndustries                   SecuritiesIndustries[]
}

model SecuritySectors {
  SecuritySectorID_PK                 String                                @id
  Position                            Int?
  TypeNumber                          Int?
  IncludeInLists                      Int?
  IncludeInReports                    Int?
  Favorite                            Int?
  Name                                String?
  ShortName                           String?
  Info                                String?
  ColorString                         String?
  AlternateColorString                String?
  TintColorString                     String?
  AlternateTintColorString            String?
  ImageData                           Bytes?
  AlternateImageData                  Bytes?
  YahooSymbol                         String?
  OtherWebsite1Symbol                 String?
  OtherWebsite2Symbol                 String?
  PercentChangeInUnitPrice            Float?
  MarketCap                           Float?
  DividendYield                       Float?
  PriceEarningsRatio                  Float?
  PriceBookRatio                      Float?
  LongTermDebtEquityRatio             Float?
  PriceFreeCashFlowRatio              Float?
  NetProfitMargin                     Float?
  ReturnOnEquity                      Float?
  Attachments                         Attachments[]
  InvestmentPortfoliosSecuritySectors InvestmentPortfoliosSecuritySectors[]
  Notes                               Notes[]
  ReportForecastDetails               ReportForecastDetails[]
  ReportGoalDetails                   ReportGoalDetails[]
  ReportsSecuritySectors              ReportsSecuritySectors[]
  SecurityIndustries                  SecurityIndustries[]
}

model SecurityTypes {
  SecurityTypeID_PK                 String                              @id
  ParentID_FK                       String?
  Position                          Int?
  TypeNumber                        Int?
  IncludeInLists                    Int?
  IncludeInReports                  Int?
  Favorite                          Int?
  Name                              String?
  ShortName                         String?
  Info                              String?
  ColorString                       String?
  AlternateColorString              String?
  TintColorString                   String?
  AlternateTintColorString          String?
  ImageData                         Bytes?
  AlternateImageData                Bytes?
  SecurityTypes                     SecurityTypes?                      @relation("SecurityTypesToSecurityTypes_ParentID_FK", fields: [ParentID_FK], references: [SecurityTypeID_PK], onDelete: Cascade)
  InvestmentPortfoliosSecurityTypes InvestmentPortfoliosSecurityTypes[]
  ReportForecastDetails             ReportForecastDetails[]
  ReportGoalDetails                 ReportGoalDetails[]
  ReportsSecurityTypes              ReportsSecurityTypes[]
  Securities                        Securities[]
  other_SecurityTypes               SecurityTypes[]                     @relation("SecurityTypesToSecurityTypes_ParentID_FK")
}

model Statements {
  StatementID_PK                                String         @id
  AccountID_NN_FK                               String
  ImportID_UK_FK                                String?        @unique(map: "sqlite_autoindex_Statements_2")
  ReconcileTypeNumber                           Int?
  StatusNumber                                  Int?
  Name                                          String?
  ShortName                                     String?
  Info                                          String?
  Date                                          Float?
  Balance                                       Float?
  StartDate                                     Float?
  EndDate                                       Float?
  StartingBalance                               Float?
  EndingBalance                                 Float?
  Accounts                                      Accounts       @relation(fields: [AccountID_NN_FK], references: [AccountID_PK], onDelete: Cascade)
  Imports_ImportsToStatements_ImportID_UK_FK    Imports?       @relation("ImportsToStatements_ImportID_UK_FK", fields: [ImportID_UK_FK], references: [ImportID_PK])
  Attachments                                   Attachments[]
  Imports_Imports_StatementID_UK_FKToStatements Imports?       @relation("Imports_StatementID_UK_FKToStatements")
  Notes                                         Notes[]
  Transactions                                  Transactions[]
}

model Tags {
  TagID_PK                        String                            @id
  ParentID_FK                     String?
  Position                        Int?
  TypeNumber                      Int?
  IncludeInLists                  Int?
  IncludeInReports                Int?
  Favorite                        Int?
  TaxCopyNumber                   Int?
  Name                            String?
  ShortName                       String?
  Info                            String?
  ColorString                     String?
  AlternateColorString            String?
  TintColorString                 String?
  AlternateTintColorString        String?
  ImageData                       Bytes?
  AlternateImageData              Bytes?
  Tags                            Tags?                             @relation("TagsToTags_ParentID_FK", fields: [ParentID_FK], references: [TagID_PK], onDelete: Cascade)
  AccountDefaultsTags             AccountDefaultsTags[]
  Attachments                     Attachments[]
  BudgetsTags                     BudgetsTags[]
  LoanTransactionDetailsTags      LoanTransactionDetailsTags[]
  Notes                           Notes[]
  ReportForecastDetails           ReportForecastDetails[]
  ReportGoalDetails               ReportGoalDetails[]
  ReportsTags                     ReportsTags[]
  ScheduledTransactionsTags       ScheduledTransactionsTags[]
  other_Tags                      Tags[]                            @relation("TagsToTags_ParentID_FK")
  TransactionRuleTransactionsTags TransactionRuleTransactionsTags[]
  TransactionsTags                TransactionsTags[]
}

model TaxCodes {
  TaxCodeID_PK  String       @id
  TypeNumber    Int?
  Code          String?
  Name          String?
  ShortName     String?
  Info          String?
  Copies        Int?
  MultiLineItem Int?
  Sorting       String?
  Sign          String?
  RecordFormat  String?
  Form          String?
  FormLine      String?
  Categories    Categories[]
}

model TransactionLogs {
  TransactionLogID_PK   String  @id
  Version_NN            String
  DeviceID_NN           String
  DeviceName            String?
  Number_NN             Int
  TimeStamp_NN          Float
  NumberOfObjectChanges Int?

  @@unique([DeviceID_NN, Number_NN, TimeStamp_NN], map: "sqlite_autoindex_TransactionLogs_3")
  @@unique([DeviceID_NN, Number_NN], map: "sqlite_autoindex_TransactionLogs_2")
}

model TransactionRuleTransactions {
  TransactionRuleTransactionID_PK                                                                                             String                            @id
  ParentID_FK                                                                                                                 String?
  Position                                                                                                                    Int?
  TransactionRuleID_UK_FK                                                                                                     String?                           @unique(map: "sqlite_autoindex_TransactionRuleTransactions_2")
  AccountID_FK                                                                                                                String?
  AccountUserID_FK                                                                                                            String?
  FlagID_FK                                                                                                                   String?
  PayeeID_FK                                                                                                                  String?
  TransactionTypeID_FK                                                                                                        String?
  CategoryID_FK                                                                                                               String?
  InvestmentTransactionDetailsID_UK_FK                                                                                        String?                           @unique(map: "sqlite_autoindex_TransactionRuleTransactions_3")
  Memo                                                                                                                        String?
  CheckNumber                                                                                                                 String?
  TransactionNumber                                                                                                           String?
  AmountTypeNumber                                                                                                            Int?
  Amount                                                                                                                      Float?
  PercentAmount                                                                                                               Float?
  StatusNumber                                                                                                                Int?
  ClearAccount                                                                                                                Int?
  ClearAccountUser                                                                                                            Int?
  ClearFlag                                                                                                                   Int?
  ClearPayee                                                                                                                  Int?
  ClearTransactionType                                                                                                        Int?
  ClearCategory                                                                                                               Int?
  ClearTags                                                                                                                   Int?
  ClearInvestmentTransactionDetails                                                                                           Int?
  ClearSecurity                                                                                                               Int?
  ClearUnits                                                                                                                  Int?
  ClearUnitPrice                                                                                                              Int?
  ClearCommission                                                                                                             Int?
  ClearMemo                                                                                                                   Int?
  ClearCheckNumber                                                                                                            Int?
  ClearTransactionNumber                                                                                                      Int?
  ClearAmount                                                                                                                 Int?
  ClearStatus                                                                                                                 Int?
  Accounts                                                                                                                    Accounts?                         @relation(fields: [AccountID_FK], references: [AccountID_PK])
  Entities                                                                                                                    Entities?                         @relation(fields: [AccountUserID_FK], references: [EntityID_PK])
  Categories                                                                                                                  Categories?                       @relation(fields: [CategoryID_FK], references: [CategoryID_PK])
  Flags                                                                                                                       Flags?                            @relation(fields: [FlagID_FK], references: [FlagID_PK])
  InvestmentTransactionDetails_InvestmentTransactionDetailsToTransactionRuleTransactions_InvestmentTransactionDetailsID_UK_FK InvestmentTransactionDetails?     @relation("InvestmentTransactionDetailsToTransactionRuleTransactions_InvestmentTransactionDetailsID_UK_FK", fields: [InvestmentTransactionDetailsID_UK_FK], references: [InvestmentTransactionDetailsID_PK])
  TransactionRuleTransactions                                                                                                 TransactionRuleTransactions?      @relation("TransactionRuleTransactionsToTransactionRuleTransactions_ParentID_FK", fields: [ParentID_FK], references: [TransactionRuleTransactionID_PK], onDelete: Cascade)
  Payees                                                                                                                      Payees?                           @relation(fields: [PayeeID_FK], references: [PayeeID_PK])
  TransactionRules_TransactionRuleTransactions_TransactionRuleID_UK_FKToTransactionRules                                      TransactionRules?                 @relation("TransactionRuleTransactions_TransactionRuleID_UK_FKToTransactionRules", fields: [TransactionRuleID_UK_FK], references: [TransactionRuleID_PK], onDelete: Cascade)
  TransactionTypes                                                                                                            TransactionTypes?                 @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK])
  InvestmentTransactionDetails_InvestmentTransactionDetails_TransactionRuleTransactionID_UK_FKToTransactionRuleTransactions   InvestmentTransactionDetails?     @relation("InvestmentTransactionDetails_TransactionRuleTransactionID_UK_FKToTransactionRuleTransactions")
  other_TransactionRuleTransactions                                                                                           TransactionRuleTransactions[]     @relation("TransactionRuleTransactionsToTransactionRuleTransactions_ParentID_FK")
  TransactionRuleTransactionsTags                                                                                             TransactionRuleTransactionsTags[]
  TransactionRules_TransactionRuleTransactionsToTransactionRules_TransactionRuleTransactionID_NN_UK_FK                        TransactionRules?                 @relation("TransactionRuleTransactionsToTransactionRules_TransactionRuleTransactionID_NN_UK_FK")
}

model TransactionRuleTransactionsTags {
  TransactionRuleTransactionID_NN_FK String
  TagID_NN_FK                        String
  Tags                               Tags                        @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)
  TransactionRuleTransactions        TransactionRuleTransactions @relation(fields: [TransactionRuleTransactionID_NN_FK], references: [TransactionRuleTransactionID_PK], onDelete: Cascade)

  @@id([TransactionRuleTransactionID_NN_FK, TagID_NN_FK])
}

model TransactionRules {
  TransactionRuleID_PK                                                                                            String                       @id
  TransactionRuleTransactionID_NN_UK_FK                                                                           String                       @unique(map: "sqlite_autoindex_TransactionRules_2")
  PayeeID_UK_FK                                                                                                   String?                      @unique(map: "sqlite_autoindex_TransactionRules_3")
  Position                                                                                                        Int?
  TypeNumber                                                                                                      Int?
  ActivationTypeNumber                                                                                            Int?
  UpdatingTypeNumber                                                                                              Int?
  ApplicationTypeNumber                                                                                           Int?
  PriorityTypeNumber                                                                                              Int?
  Name                                                                                                            String?
  ShortName                                                                                                       String?
  Info                                                                                                            String?
  OverallParametersCombinationTypeNumber                                                                          Int?
  ObjectMatchesCombinationTypeNumber                                                                              Int?
  Payees_PayeesToTransactionRules_PayeeID_UK_FK                                                                   Payees?                      @relation("PayeesToTransactionRules_PayeeID_UK_FK", fields: [PayeeID_UK_FK], references: [PayeeID_PK], onDelete: Cascade)
  TransactionRuleTransactions_TransactionRuleTransactionsToTransactionRules_TransactionRuleTransactionID_NN_UK_FK TransactionRuleTransactions  @relation("TransactionRuleTransactionsToTransactionRules_TransactionRuleTransactionID_NN_UK_FK", fields: [TransactionRuleTransactionID_NN_UK_FK], references: [TransactionRuleTransactionID_PK], onDelete: Cascade)
  ObjectMatches                                                                                                   ObjectMatches[]
  Payees_Payees_TransactionRuleID_UK_FKToTransactionRules                                                         Payees?                      @relation("Payees_TransactionRuleID_UK_FKToTransactionRules")
  TransactionRuleTransactions_TransactionRuleTransactions_TransactionRuleID_UK_FKToTransactionRules               TransactionRuleTransactions? @relation("TransactionRuleTransactions_TransactionRuleID_UK_FKToTransactionRules")
}

model TransactionTypes {
  TransactionTypeID_PK        String                        @id
  TypeNumber                  Int?
  AmountRestrictionTypeNumber Int?
  SharesAffectTypeNumber      Int?
  IncludeInLists              Int?
  IncludeInReports            Int?
  Favorite                    Int?
  Name                        String?
  ShortName                   String?
  Info                        String?
  ColorString                 String?
  AlternateColorString        String?
  TintColorString             String?
  AlternateTintColorString    String?
  ImageData                   Bytes?
  AlternateImageData          Bytes?
  Accounts                    Accounts[]
  Attachments                 Attachments[]
  LoanTransactionDetails      LoanTransactionDetails[]
  Notes                       Notes[]
  ReportForecastDetails       ReportForecastDetails[]
  ReportGoalDetails           ReportGoalDetails[]
  ReportsTransactionTypes     ReportsTransactionTypes[]
  ScheduledTransactions       ScheduledTransactions[]
  TransactionRuleTransactions TransactionRuleTransactions[]
  Transactions                Transactions[]
}

model Transactions {
  TransactionID_PK                                                                                             String                        @id
  ParentID_FK                                                                                                  String?
  Position                                                                                                     Int?
  AccountID_FK                                                                                                 String?
  AccountUserID_FK                                                                                             String?
  FlagID_FK                                                                                                    String?
  PayeeID_FK                                                                                                   String?
  TransactionTypeID_FK                                                                                         String?
  CategoryID_FK                                                                                                String?
  InvestmentTransactionDetailsID_UK_FK                                                                         String?                       @unique(map: "sqlite_autoindex_Transactions_2")
  LoanTransactionDetailsID_UK_FK                                                                               String?                       @unique(map: "sqlite_autoindex_Transactions_3")
  LinkedTransferID_UK_FK                                                                                       String?                       @unique(map: "sqlite_autoindex_Transactions_4")
  ScheduledTransactionID_FK                                                                                    String?
  ImportedTransactionID_UK_FK                                                                                  String?                       @unique(map: "sqlite_autoindex_Transactions_5")
  StatementID_FK                                                                                               String?
  OriginNumber                                                                                                 Int?
  UniqueID                                                                                                     String?
  OriginalCurrencyCode                                                                                         String?
  OriginalCurrencyRate                                                                                         Float?
  CreationDate                                                                                                 Float?
  ModifiedDate                                                                                                 Float?
  Date                                                                                                         Float?
  ClearedDate                                                                                                  Float?
  Memo                                                                                                         String?
  CheckNumber                                                                                                  String?
  NeedToPrintCheck                                                                                             Int?
  TransactionNumber                                                                                            String?
  Amount                                                                                                       Float?
  AmountAppliedToBalance                                                                                       Float?
  StatusNumber                                                                                                 Int?
  Accounts                                                                                                     Accounts?                     @relation(fields: [AccountID_FK], references: [AccountID_PK], onDelete: Cascade)
  Entities                                                                                                     Entities?                     @relation(fields: [AccountUserID_FK], references: [EntityID_PK])
  Categories                                                                                                   Categories?                   @relation(fields: [CategoryID_FK], references: [CategoryID_PK])
  Flags                                                                                                        Flags?                        @relation(fields: [FlagID_FK], references: [FlagID_PK])
  ImportedTransactions_ImportedTransactionsToTransactions_ImportedTransactionID_UK_FK                          ImportedTransactions?         @relation("ImportedTransactionsToTransactions_ImportedTransactionID_UK_FK", fields: [ImportedTransactionID_UK_FK], references: [ImportedTransactionID_PK])
  InvestmentTransactionDetails_InvestmentTransactionDetailsToTransactions_InvestmentTransactionDetailsID_UK_FK InvestmentTransactionDetails? @relation("InvestmentTransactionDetailsToTransactions_InvestmentTransactionDetailsID_UK_FK", fields: [InvestmentTransactionDetailsID_UK_FK], references: [InvestmentTransactionDetailsID_PK])
  Transactions_TransactionsToTransactions_LinkedTransferID_UK_FK                                               Transactions?                 @relation("TransactionsToTransactions_LinkedTransferID_UK_FK", fields: [LinkedTransferID_UK_FK], references: [TransactionID_PK])
  LoanTransactionDetails_LoanTransactionDetailsToTransactions_LoanTransactionDetailsID_UK_FK                   LoanTransactionDetails?       @relation("LoanTransactionDetailsToTransactions_LoanTransactionDetailsID_UK_FK", fields: [LoanTransactionDetailsID_UK_FK], references: [LoanTransactionDetailsID_PK])
  Transactions_TransactionsToTransactions_ParentID_FK                                                          Transactions?                 @relation("TransactionsToTransactions_ParentID_FK", fields: [ParentID_FK], references: [TransactionID_PK], onDelete: Cascade)
  Payees                                                                                                       Payees?                       @relation(fields: [PayeeID_FK], references: [PayeeID_PK])
  ScheduledTransactions                                                                                        ScheduledTransactions?        @relation(fields: [ScheduledTransactionID_FK], references: [ScheduledTransactionID_PK])
  Statements                                                                                                   Statements?                   @relation(fields: [StatementID_FK], references: [StatementID_PK])
  TransactionTypes                                                                                             TransactionTypes?             @relation(fields: [TransactionTypeID_FK], references: [TransactionTypeID_PK])
  Attachments                                                                                                  Attachments[]
  ImportedTransactions_ImportedTransactions_TransactionID_UK_FKToTransactions                                  ImportedTransactions?         @relation("ImportedTransactions_TransactionID_UK_FKToTransactions")
  InvestmentTransactionDetails_InvestmentTransactionDetails_TransactionID_UK_FKToTransactions                  InvestmentTransactionDetails? @relation("InvestmentTransactionDetails_TransactionID_UK_FKToTransactions")
  LoanTransactionDetails_LoanTransactionDetails_TransactionID_UK_FKToTransactions                              LoanTransactionDetails?       @relation("LoanTransactionDetails_TransactionID_UK_FKToTransactions")
  Notes                                                                                                        Notes[]
  ReportsTransactions                                                                                          ReportsTransactions[]
  other_Transactions_TransactionsToTransactions_LinkedTransferID_UK_FK                                         Transactions?                 @relation("TransactionsToTransactions_LinkedTransferID_UK_FK")
  other_Transactions_TransactionsToTransactions_ParentID_FK                                                    Transactions[]                @relation("TransactionsToTransactions_ParentID_FK")
  TransactionsTags                                                                                             TransactionsTags[]
}

model TransactionsTags {
  TransactionID_NN_FK String
  TagID_NN_FK         String
  Tags                Tags         @relation(fields: [TagID_NN_FK], references: [TagID_PK], onDelete: Cascade)
  Transactions        Transactions @relation(fields: [TransactionID_NN_FK], references: [TransactionID_PK], onDelete: Cascade)

  @@id([TransactionID_NN_FK, TagID_NN_FK])
}

model Websites {
  WebsiteID_PK                                               String         @id
  LocationID_UK_FK                                           String?        @unique(map: "sqlite_autoindex_Websites_2")
  AccountGroupID_UK_FK                                       String?        @unique(map: "sqlite_autoindex_Websites_3")
  AccountID_UK_FK                                            String?        @unique(map: "sqlite_autoindex_Websites_4")
  PayeeID_UK_FK                                              String?        @unique(map: "sqlite_autoindex_Websites_5")
  SecurityID_UK_FK                                           String?        @unique(map: "sqlite_autoindex_Websites_6")
  Position                                                   Int?
  TypeNumber                                                 Int?
  Favorite                                                   Int?
  Name                                                       String?
  ShortName                                                  String?
  Info                                                       String?
  ColorString                                                String?
  AlternateColorString                                       String?
  TintColorString                                            String?
  AlternateTintColorString                                   String?
  ImageData                                                  Bytes?
  AlternateImageData                                         Bytes?
  URL                                                        String?
  AccountGroups_AccountGroupsToWebsites_AccountGroupID_UK_FK AccountGroups? @relation("AccountGroupsToWebsites_AccountGroupID_UK_FK", fields: [AccountGroupID_UK_FK], references: [AccountGroupID_PK], onDelete: Cascade)
  Accounts_AccountsToWebsites_AccountID_UK_FK                Accounts?      @relation("AccountsToWebsites_AccountID_UK_FK", fields: [AccountID_UK_FK], references: [AccountID_PK], onDelete: Cascade)
  Locations_LocationsToWebsites_LocationID_UK_FK             Locations?     @relation("LocationsToWebsites_LocationID_UK_FK", fields: [LocationID_UK_FK], references: [LocationID_PK], onDelete: Cascade)
  Payees_PayeesToWebsites_PayeeID_UK_FK                      Payees?        @relation("PayeesToWebsites_PayeeID_UK_FK", fields: [PayeeID_UK_FK], references: [PayeeID_PK], onDelete: Cascade)
  Securities_SecuritiesToWebsites_SecurityID_UK_FK           Securities?    @relation("SecuritiesToWebsites_SecurityID_UK_FK", fields: [SecurityID_UK_FK], references: [SecurityID_PK], onDelete: Cascade)
  AccountGroups_AccountGroups_WebsiteID_UK_FKToWebsites      AccountGroups? @relation("AccountGroups_WebsiteID_UK_FKToWebsites")
  Accounts_Accounts_WebsiteID_UK_FKToWebsites                Accounts?      @relation("Accounts_WebsiteID_UK_FKToWebsites")
  Locations_Locations_WebsiteID_UK_FKToWebsites              Locations?     @relation("Locations_WebsiteID_UK_FKToWebsites")
  Payees_Payees_WebsiteID_UK_FKToWebsites                    Payees?        @relation("Payees_WebsiteID_UK_FKToWebsites")
  Securities_Securities_WebsiteID_UK_FKToWebsites            Securities?    @relation("Securities_WebsiteID_UK_FKToWebsites")
}

model fundCategories {
  SecurityFundCategoryID_PK                  String                                       @id
  Position                                   Int?
  TypeNumber                                 Int?
  IncludeInLists                             Int?
  IncludeInReports                           Int?
  Favorite                                   Int?
  Name                                       String?
  ShortName                                  String?
  Info                                       String?
  ColorString                                String?
  AlternateColorString                       String?
  TintColorString                            String?
  AlternateTintColorString                   String?
  ImageData                                  Bytes?
  AlternateImageData                         Bytes?
  Attachments                                Attachments[]
  InvestmentPortfoliosSecurityFundCategories InvestmentPortfoliosSecurityFundCategories[]
  Notes                                      Notes[]
  ReportForecastDetails                      ReportForecastDetails[]
  ReportGoalDetails                          ReportGoalDetails[]
  ReportsSecurityFundCategories              ReportsSecurityFundCategories[]
  Securities                                 Securities[]
}
<svg id="mermaid-0" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="55" style="max-width: 324.328125px;" viewBox="0 0 324.328125 55"><style>#mermaid-0 {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#000000;}#mermaid-0 .error-icon{fill:#552222;}#mermaid-0 .error-text{fill:#552222;stroke:#552222;}#mermaid-0 .edge-thickness-normal{stroke-width:2px;}#mermaid-0 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-0 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-0 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-0 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-0 .marker{fill:#000000;stroke:#000000;}#mermaid-0 .marker.cross{stroke:#000000;}#mermaid-0 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-0 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#000000;}#mermaid-0 .cluster-label text{fill:#333;}#mermaid-0 .cluster-label span{color:#333;}#mermaid-0 .label text,#mermaid-0 span{fill:#000000;color:#000000;}#mermaid-0 .node rect,#mermaid-0 .node circle,#mermaid-0 .node ellipse,#mermaid-0 .node polygon,#mermaid-0 .node path{fill:#cde498;stroke:#13540c;stroke-width:1px;}#mermaid-0 .node .label{text-align:center;}#mermaid-0 .node.clickable{cursor:pointer;}#mermaid-0 .arrowheadPath{fill:green;}#mermaid-0 .edgePath .path{stroke:#000000;stroke-width:2.0px;}#mermaid-0 .flowchart-link{stroke:#000000;fill:none;}#mermaid-0 .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-0 .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-0 .cluster rect{fill:#cdffb2;stroke:#6eaa49;stroke-width:1px;}#mermaid-0 .cluster text{fill:#333;}#mermaid-0 .cluster span{color:#333;}#mermaid-0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(78.1578947368, 58.4615384615%, 84.5098039216%);border:1px solid #6eaa49;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-0 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"></g><g class="edgeLabels"></g><g class="nodes"><g class="node default" id="flowchart-a-2" transform="translate(162.1640625,27.5)" style="opacity: 1;"><rect rx="0" ry="0" x="-154.1640625" y="-19.5" width="308.328125" height="39" class="label-container" style="fill:#faa;"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-144.1640625,-9.5)"><foreignObject width="288.328125" height="19"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;">Maximum text size in diagram exceeded</div></foreignObject></g></g></g></g></g></g></svg>

Seems this is configurable: https://stackoverflow.com/a/63168255

FYI: Generated mermaid ERDs can now be rendered in GitHub READMEs and issues

erDiagram

  listingsAndReviews {
      String z_id
    String access
    Int accommodates
    String amenities
    Decimal bathrooms
    String bed_type
    Int bedrooms
    Int beds
    DateTime calendar_last_scraped
    String cancellation_policy
    Decimal cleaning_fee
    String description
    Decimal extra_people
    DateTime first_review
    Decimal guests_included
    String house_rules
    String interaction
    DateTime last_review
    DateTime last_scraped
    String listing_url
    String maximum_nights
    String minimum_nights
    Decimal monthly_price
    String name
    String neighborhood_overview
    String notes
    Int number_of_reviews
    Decimal price
    String property_type
    Int reviews_per_month
    String room_type
    Decimal security_deposit
    String space
    String summary
    String transit
    Decimal weekly_price
    }
  

  ListingsAndReviewsAddress {
      String country
    String country_code
    String government_area
    String market
    String street
    String suburb
    }
  

  ListingsAndReviewsAddressLocation {
      Float coordinates
    Boolean is_location_exact
    String type
    }
  

  ListingsAndReviewsAvailability {
      Int availability_30
    Int availability_365
    Int availability_60
    Int availability_90
    }
  

  ListingsAndReviewsHost {
      String host_about
    Boolean host_has_profile_pic
    String host_id
    Boolean host_identity_verified
    Boolean host_is_superhost
    Int host_listings_count
    String host_location
    String host_name
    String host_neighbourhood
    String host_picture_url
    Int host_response_rate
    String host_response_time
    String host_thumbnail_url
    Int host_total_listings_count
    String host_url
    String host_verifications
    }
  

  ListingsAndReviewsImages {
      String medium_url
    String picture_url
    String thumbnail_url
    String xl_picture_url
    }
  

  ListingsAndReviewsReviewScores {
      Int review_scores_accuracy
    Int review_scores_checkin
    Int review_scores_cleanliness
    Int review_scores_communication
    Int review_scores_location
    Int review_scores_rating
    Int review_scores_value
    }
  

  ListingsAndReviewsReviews {
      String id
    String comments
    DateTime date
    String listing_id
    String reviewer_id
    String reviewer_name
    }
  
    listingsAndReviews ||--|| ListingsAndReviewsAddress : "address"
    listingsAndReviews ||--|| ListingsAndReviewsAvailability : "availability"
    listingsAndReviews ||--|| ListingsAndReviewsHost : "host"
    listingsAndReviews ||--|| ListingsAndReviewsImages : "images"
    listingsAndReviews o|--|| ListingsAndReviewsReviewScores : "review_scores"
    listingsAndReviews }o--|| ListingsAndReviewsReviews : "reviews"
    ListingsAndReviewsAddress o{--|| ListingsAndReviewsAddressLocation : "location"
Loading

Does not work on Windows

After fixing #1 manually, I still did not get a svg file. I could pinpoint it to

child_process.spawnSync(`./node_modules/.bin/mmdc`, [
'-i',
`prisma/input.mmd`,
'-o',
output,
'-t',
theme,
]);
which does not work on Windows.

A bit of hacking in generate.js did not help, so I uncommented the line that deletes the temp file afterwards, and ran the following command manually: npx mmdc -i prisma/input.mmd -o C:\\Users\\Jan\\Documents\\throwaway\\repro8264\\prisma\\ERD.svg -t forest.

Maybe that can be turned into a cross platform solution to this problem.

Unable to create svg file

schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

// ER図作成用
generator erd {
  provider = "prisma-erd-generator"
  output   = "../doc/ERD.svg"
  theme    = "forest"
}

// ユーザーデータ管理用
model User {
  // ID
  id    Int     @id @default(autoincrement())
  // メールアドレス
  email String  @unique
  // 氏名
  name  String?
  // 年齢
  age   Int?

  // 登録日時
  createdAt DateTime @default(now()) @map("created_at")
  // 更新日時
  updatedAt DateTime @default(now()) @map("updated_at")

  // プロフィール(One to One)
  profile Profile?
  // 記事(One to Many)
  posts   Post[]

  // テーブルの物理名
  @@map("users")
}

// プロフィール管理用
model Profile {
  // ID
  id       Int    @id @default(autoincrement())
  // ニックネーム
  nickName String @map("nick_name")

  // 登録日時
  createdAt DateTime @default(now()) @map("created_at")
  // 更新日時
  updatedAt DateTime @default(now()) @map("updated_at")

  // 親テーブルの関連づけ
  userId Int  @unique
  user   User @relation(fields: [userId], references: [id])

  // テーブルの物理名
  @@map("profile")
}

// 記事管理用
model Post {
  // ID
  id    Int    @id @default(autoincrement())
  // タイトル
  title String @map("title")

  // 登録日時
  createdAt DateTime @default(now()) @map("created_at")
  // 更新日時
  updatedAt DateTime @default(now()) @map("updated_at")

  // 親テーブルの関連づけ
  author   User @relation(fields: [authorId], references: [id])
  authorId Int

  // テーブルの物理名
  @@map("posts")
}

generate

npx prisma generate

result

prisma.mmd

What should i do?

Option to ignore certain tables

How about a flag/regex to ignore certain tables/relations?

I got some "system" tables that I don't really want to end up in the ERD but they will obviously be introspected by prisma.

What do you think of that? Could be a good complement for #72.

Related: prisma/prisma#807

Generating files that don't render

I'm able to successfully generate files of the different extensions but they all seem to be empty/not working.

I unfortunately cannot provide my full schema file as it is work related but if I need to then I can obfuscate the names.

project
|__ prisma
|____schema.prisma
|____ERD.svg
generator erd {
	provider = "node node_modules/prisma-erd-generator"
	output = "./ERD.svg"
}
... My prisma models
  • I have no reason to believe my models are improperly defined since prisma has been working as intended
  • My file structure seems in line with what this package expects (see above).
  • I have mermaid-js/mermaid-cli and prisma-erd-generator in my package.json and installed.

Here are my output files

ERD.svg
ERD

ERD.png
ERD

ERD.md did include my models but using mermaid markdown preview in vscode doesn't show anything

```mermaid
erDiagram

...my models```

[Windows] - ERD Generator fails if current directory path contains spaces

Hi!

First of all, really good tool!

The tool is not able to generate when the current directory contains spaces. Following is an example -

mermaid command:  C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\node_modules\.bin\mmdc -i C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\prisma.mmd -o C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\ERD.svg -t forest -c C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\config.json
Error: 
Error: Command failed: C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\node_modules\.bin\mmdc -i C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\prisma.mmd -o C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\ERD.svg -t forest -c C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\config.json
    at checkExecSyncError (node:child_process:828:11)
    at Object.execSync (node:child_process:899:15)
    at Object.exports.default [as onGenerate] (C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\node_modules\prisma-erd-generator\dist\generate.js:264:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\node_modules\@prisma\generator-helper\dist\generatorHandler.js:34:24)


✔ Generated Prisma Client (4.1.0 | library) to .\node_modules\@prisma\client in 199ms

I took the mermaid command and wrapped up in quotes and I was able to execute it in Powershell

& "C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\node_modules\.bin\mmdc" -i "C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\prisma.mmd" -o "C:\Users\Pranav\OneDrive - Solutions Pvt. Ltd\Solutions\Tome\Schema\ERD.svg" -t forest -c "C:\Users\Pranav\AppData\Local\Temp\prisma-erd-HK4hIm\config.json"

Works locally but not when generated inside Dockerfile (node:15)

Error:

#14 0.689 > npx prisma generate
#14 0.689
#14 2.049 Prisma schema loaded from prisma/schema.prisma
#14 16.61 Error:
#14 16.61 Error: Command failed: /app/node_modules/.bin/mmdc -i /tmp/prisma-erd-iGMeMD/prisma.mmd -o /app/prisma/ERD.pdf -t forest -c /tmp/prisma-erd-iGMeMD/config.json
#14 16.61     at checkExecSyncError (node:child_process:707:11)
#14 16.61     at Object.execSync (node:child_process:744:15)
#14 16.61     at Object.exports.default [as onGenerate] (/app/node_modules/prisma-erd-generator/dist/generate.js:187:23)
#14 16.61     at processTicksAndRejections (node:internal/process/task_queues:94:5)
#14 16.61     at async LineStream.<anonymous> (/app/node_modules/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
#14 16.61
#14 16.61
#14 16.61 ✔ Generated Prisma JSON Schema Generator to ./prisma/generated in 
38ms
#14 16.61
#14 16.61 ✔ Generated DBML Schema to ./prisma/generated in 40ms
#14 16.61
#14 16.61 ✔ Generated Prisma Docs Generator to ./prisma/generated/database-docs in 116ms
#14 16.61
#14 16.61 ✔ Generated Prisma Client (2.27.0) to ./node_modules/@prisma/client in 573ms
#14 16.61
#14 16.61 ✔ Generated Prisma NestJS/GraphQL to ./node_modules/@prisma/client/nestjs-graphql in 11.67s
#14 16.61
------
executor failed running [/bin/sh -c npm run prebuild]: exit code: 1

Version:
"prisma-erd-generator": "^0.8.1"

Generator Part inside schema.prisma:

...
generator erd {
  provider = "prisma-erd-generator"
  output   = "./ERD.pdf"
}
...

Dockerfile:

FROM node:15-alpine AS builder
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
COPY nest-cli.json ./
COPY ./src/ ./src/
COPY ./prisma/ ./prisma/
RUN npm ci --quiet
RUN npx prisma generate # <= failing line

Allow hiding ENUM tables

It would be nice to be able to hide enum tables with an extra flag in the schema.
When you have many enums, the diagram is not so easy to understand anymore.

prisma:GeneratorProcess Error: ENOENT: no such file or directory, scandir '...\node_modules\prisma-erd-generator\node_modules\@prisma\engines' +1ms

I think the logic to find the binary does not work properly when using the generator via Npm:

C:\Users\Jan\Documents\throwaway\repro8264>npx prisma generate
  prisma:loadEnv project root found at C:\Users\Jan\Documents\throwaway\repro8264\package.json +0ms
  prisma:tryLoadEnv Environment variables loaded from C:\Users\Jan\Documents\throwaway\repro8264\.env +0ms
[dotenv][DEBUG] did not match key and value when parsing line 1: # Environment variables declared in this file are automatically made available to Prisma.
[dotenv][DEBUG] did not match key and value when parsing line 2: # See the documentation for more detail: https://pris.ly/d/prisma-schema#using-environment-variables
[dotenv][DEBUG] did not match key and value when parsing line 3:
[dotenv][DEBUG] did not match key and value when parsing line 4: # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server (Preview) and MongoDB (Preview).
[dotenv][DEBUG] did not match key and value when parsing line 5: # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
[dotenv][DEBUG] did not match key and value when parsing line 6:
Environment variables loaded from .env
  prisma:engines using Node API: false +0ms
  prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt +2ms
Prisma schema loaded from prisma\schema.prisma
  prisma:getConfig Using Query Engine Binary at: C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma\query-engine-windows.exe +0ms
  prisma:getDMMF Using Query Engine Binary at: C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma\query-engine-windows.exe +0ms
  prisma:generator prismaCLIDir C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma +0ms
  prisma:generator prismaClientDir C:\Users\Jan\Documents\throwaway\repro8264\node_modules\@prisma\client +0ms
  prisma:generator baseDir C:\Users\Jan\Documents\throwaway\repro8264\prisma +1ms
  prisma:GeneratorProcess internal/fs/utils.js:307 +0ms
  prisma:GeneratorProcess     throw err; +0ms
  prisma:GeneratorProcess     ^ +1ms
  prisma:GeneratorProcess Error: ENOENT: no such file or directory, scandir 'C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma-erd-generator\node_modules\@prisma\engines' +1ms
  prisma:GeneratorProcess     at Object.readdirSync (fs.js:1021:3) +1ms
  prisma:GeneratorProcess     at Object.<anonymous> (C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma-erd-generator\dist\generate.js:30:33) +0ms
  prisma:GeneratorProcess     at Module._compile (internal/modules/cjs/loader.js:1063:30) +1ms
  prisma:GeneratorProcess     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) +1ms
  prisma:GeneratorProcess     at Module.load (internal/modules/cjs/loader.js:928:32) +1ms
  prisma:GeneratorProcess     at Function.Module._load (internal/modules/cjs/loader.js:769:14) +1ms
  prisma:GeneratorProcess     at Module.require (internal/modules/cjs/loader.js:952:19) +0ms
  prisma:GeneratorProcess     at require (internal/modules/cjs/helpers.js:88:18) +1ms
  prisma:GeneratorProcess     at Object.<anonymous> (C:\Users\Jan\Documents\throwaway\repro8264\node_modules\prisma-erd-generator\dist\index.js:8:36) +1ms
  prisma:GeneratorProcess     at Module._compile (internal/modules/cjs/loader.js:1063:30) { +1ms
  prisma:GeneratorProcess   errno: -4058, +1ms
  prisma:GeneratorProcess   syscall: 'scandir', +0ms
  prisma:GeneratorProcess   code: 'ENOENT', +1ms
  prisma:GeneratorProcess   path: 'C:\\Users\\Jan\\Documents\\throwaway\\repro8264\\node_modules\\prisma-erd-generator\\node_modules\\@prisma\\engines' +1ms
  prisma:GeneratorProcess } +0ms
  prisma:GeneratorProcess 2021-07-16T12:40:18.130Z prisma:client:generator requiredEngine: queryEngine +736ms

Adding '..', '..', to the path it tries to read, makes it access the correct dependency folder and let's it progress further.

In theory you should not even have to read the dependency like that at all, but request the correct generator in the manifest. Unfortunately we do not have good documentation on it, but it would look like this: https://github.com/maoosi/prisma-appsync/blob/feae1a466490c610a1f2d58a9cfb85971114ac13/src/generator/prisma-appsync.ts#L16 The paths of these binaries, provided by the generate process, would end up in binaryPaths in the returned object.

That might also let you get rid of the @prisma/engines dependency.

Prisma One-to-many Relationships Always Show as Required?

macOS BigSur
node v17.2.0

Hi! It's very possible this question is not an actual issue with the ERD generator but rather caused by how Prisma handles relationships. However, I can't seem to find any clear information online about it.

To demonstrate, I'll use the example from the bottom of Prisma's One-to-many documentation page. In this example the docs say: "you can create a Post without assigning a User". This is true, posts can be created without a user with no problems. However, the ERD generated shows that Post-to-User is a required relationship (image below). Is this an issue with the ERD generator? Or is there something I don't fully understand about One-to-many relationships in Prisma?

model User {
  id    Int    @id @default(autoincrement())
  posts Post[]
}

model Post {
  id       Int   @id @default(autoincrement())
  author   User? @relation(fields: [authorId], references: [id])
  authorId Int?
}

Screen Shot 2022-08-17 at 2 39 06 PM

Upcoming rename of `@prisma/sdk` to `@prisma/internals` with Prisma 4

Hey,

Jan from Prisma Engineering here.

Quick heads up that we will soon rename our @prisma/sdk package to @prisma/internals with Prisma 4, which we plan to release on June 28th (soon!).

The @prisma/sdk package was meant as an Prisma internal package only, but somehow it leaked out over time and is now used across all kinds of tools - including yours of course 😄

With the rename of the Npm package we want to make it clearer that we can not give any API guarantees for @prisma/internals, might need to introduce breaking changes to the API from time to time and will not follow semantic versioning (breaking changes only in major upgrade) with it. We think that it is better communicated with internals than with sdk.
With Prisma 4, besides the package name nothing should change though.

Additionally it would be super helpful if you could help us gain an understanding where, how and why you are using @prisma/sdk (soon @prisma/internals, remember 😀) to achieve, what exactly. We want to cleanup that package and your feedback will be valuable to us to define a better API.

Looking forward to your feedback.

Best
Jan & your friends at Prisma

PS: Are you using Prisma.dmmf from import { Prisma } from '@prisma/client' in your code somewhere by chance? That will also change soon and not include the Prisma.dmmf.schema sub property. Instead you can use getDmmf from @prisma/internals moving forward.

braintree/sanitize-url audit issue

Mermaid relies on braintree/sanitize-url, which has a security issue that was patched in 6.0.0. This dependency was fixed in mermaid >9.0.0, however prisma-erd-generator still reference an older 8.14.0 version. Can we get a new release with updated dependencies?

TypeError: Cannot read properties of undefined (reading 'dbName') version `0.10.0`

TypeError: Cannot read properties of undefined (reading 'dbName')

schema

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

generator typegraphql {
  provider = "typegraphql-prisma"
}

generator erd {
  provider = "prisma-erd-generator"
}

model Message {
  messageId Int      @id @default(autoincrement()) @map("message_id")
  sender    String
  content   String
  timestamp DateTime @default(now())
  group     Group    @relation(fields: [groupId], references: [groupId], onDelete: Cascade)
  groupId   String
}

model Group {
  groupId  String    @id @default(uuid()) @map("group_id")
  name     String?
  messages Message[]
  app      App       @relation(fields: [appId], references: [appId], onDelete: Cascade)
  appId    String
}

model App {
  appId          String  @id @default(uuid()) @map("app_id")
  name           String  @unique
  messageCounter Int     @default(0) @map("message_counter")
  groups         Group[]
}

dataModelString

{
    "enums": [],
    "models": [
      {
        "name": "Message",
        "dbName": null,
        "fields": [
          {
            "name": "messageId",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": true,
            "isReadOnly": false,
            "type": "Int",
            "hasDefaultValue": true,
            "default": {
              "name": "autoincrement",
              "args": []
            },
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "sender",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "content",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "timestamp",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "DateTime",
            "hasDefaultValue": true,
            "default": {
              "name": "now",
              "args": []
            },
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "group",
            "kind": "object",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "Group",
            "hasDefaultValue": false,
            "relationName": "GroupToMessage",
            "relationFromFields": [
              "groupId"
            ],
            "relationToFields": [
              "groupId"
            ],
            "relationOnDelete": "Cascade",
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "groupId",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": true,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          }
        ],
        "isGenerated": false,
        "primaryKey": null,
        "uniqueFields": [],
        "uniqueIndexes": []
      },
      {
        "name": "Group",
        "dbName": null,
        "fields": [
          {
            "name": "groupId",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": true,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": true,
            "default": {
              "name": "uuid",
              "args": []
            },
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "name",
            "kind": "scalar",
            "isList": false,
            "isRequired": false,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "messages",
            "kind": "object",
            "isList": true,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "Message",
            "hasDefaultValue": false,
            "relationName": "GroupToMessage",
            "relationFromFields": [],
            "relationToFields": [],
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "app",
            "kind": "object",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "App",
            "hasDefaultValue": false,
            "relationName": "AppToGroup",
            "relationFromFields": [
              "appId"
            ],
            "relationToFields": [
              "appId"
            ],
            "relationOnDelete": "Cascade",
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "appId",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": true,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          }
        ],
        "isGenerated": false,
        "primaryKey": null,
        "uniqueFields": [],
        "uniqueIndexes": []
      },
      {
        "name": "App",
        "dbName": null,
        "fields": [
          {
            "name": "appId",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": true,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": true,
            "default": {
              "name": "uuid",
              "args": []
            },
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "name",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": true,
            "isId": false,
            "isReadOnly": false,
            "type": "String",
            "hasDefaultValue": false,
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "messageCounter",
            "kind": "scalar",
            "isList": false,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "Int",
            "hasDefaultValue": true,
            "default": 0.0,
            "isGenerated": false,
            "isUpdatedAt": false
          },
          {
            "name": "groups",
            "kind": "object",
            "isList": true,
            "isRequired": true,
            "isUnique": false,
            "isId": false,
            "isReadOnly": false,
            "type": "Group",
            "hasDefaultValue": false,
            "relationName": "AppToGroup",
            "relationFromFields": [],
            "relationToFields": [],
            "isGenerated": false,
            "isUpdatedAt": false
          }
        ],
        "isGenerated": false,
        "primaryKey": null,
        "uniqueFields": [],
        "uniqueIndexes": []
      }
    ]
  }

mapped models

{mappedModels: [
  {
    name: 'Message',
    dbName: null,
    fields: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
    isGenerated: false,
    primaryKey: null,
    uniqueFields: [],
    uniqueIndexes: []
  },
  {
    name: 'Group',
    dbName: null,
    fields: [ [Object], [Object], [Object], [Object], [Object] ],
    isGenerated: false,
    primaryKey: null,
    uniqueFields: [],
    uniqueIndexes: []
  },
  {
    name: 'App',
    dbName: null,
    fields: [ [Object], [Object], [Object], [Object] ],
    isGenerated: false,
    primaryKey: null,
    uniqueFields: [],
    uniqueIndexes: []
  }
]}

mentioned in #62

Running tests locally fails

Error: 
Error: could not parse datamodel
    at Object.exports.default [as onGenerate] (/workspace/prisma-erd-generator/dist/generate.js:175:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/workspace/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)


 FAIL  __tests__/Enums.ts (6.909 s)
  ● enums.prisma

    Command failed: npx prisma generate --schema ./prisma/enums.prisma
    Error: 
    Error: could not parse datamodel

      173 |         const datamodelString = await parseDatamodel(queryEngine, options.datamodel, tmpDir);
      174 |         if (!datamodelString)
    > 175 |             throw new Error('could not parse datamodel');
          |                   ^
      176 |         let dml = JSON.parse(datamodelString);
      177 |         // updating dml to map to db table and column names (@map && @@map)
      178 |         dml.models = (0, exports.mapPrismaToDb)(dml.models, options.datamodel);

      at Object.exports.default [as onGenerate] (dist/generate.js:175:19)
      at async LineStream.<anonymous> (node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
      at Object.<anonymous> (__tests__/Enums.ts:7:19)

Error: 
Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-r1kvOZ/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/ManyToMany.svg -t forest -c /tmp/prisma-erd-r1kvOZ/config.json
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at Object.exports.default [as onGenerate] (/workspace/prisma-erd-generator/dist/generate.js:203:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/workspace/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)


 FAIL  __tests__/manyToMany.test.ts (7.413 s)
  ● many-to-many.prisma

    Command failed: npx prisma generate --schema ./prisma/many-to-many.prisma
    Error: 
    Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-r1kvOZ/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/ManyToMany.svg -t forest -c /tmp/prisma-erd-r1kvOZ/config.json

      201 |             }
      202 |         }
    > 203 |         child_process.execSync(`${mermaidCliNodePath} -i ${tempMermaidFile} -o ${output} -t ${theme} -c ${tempConfigFile}`, {
          |                       ^
      204 |             stdio: 'ignore',
      205 |         });
      206 |         // throw error if file was not created

      at Object.exports.default [as onGenerate] (dist/generate.js:203:23)
      at async LineStream.<anonymous> (node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
      at Object.<anonymous> (__tests__/manyToMany.test.ts:7:19)

Error: 
Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-rFlswF/prisma.mmd -o /workspace/prisma-erd-generator/ERD.svg -t default -c /tmp/prisma-erd-rFlswF/config.json
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at Object.exports.default [as onGenerate] (/workspace/prisma-erd-generator/dist/generate.js:203:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/workspace/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)


 FAIL  __tests__/genericModels.test.ts (7.581 s)
  ● schema.prisma

    Command failed: npx prisma generate
    Error: 
    Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-rFlswF/prisma.mmd -o /workspace/prisma-erd-generator/ERD.svg -t default -c /tmp/prisma-erd-rFlswF/config.json

      201 |             }
      202 |         }
    > 203 |         child_process.execSync(`${mermaidCliNodePath} -i ${tempMermaidFile} -o ${output} -t ${theme} -c ${tempConfigFile}`, {
          |                       ^
      204 |             stdio: 'ignore',
      205 |         });
      206 |         // throw error if file was not created

      at Object.exports.default [as onGenerate] (dist/generate.js:203:23)
      at async LineStream.<anonymous> (node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
      at Object.<anonymous> (__tests__/genericModels.test.ts:5:19)

Error: 
✔ Generated Prisma Client (3.6.0 | library) to ./node_modules/@prisma/client in 63ms

Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-m3S4d2/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/36.png -t forest -c /tmp/prisma-erd-m3S4d2/config.json
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at Object.exports.default [as onGenerate] (/workspace/prisma-erd-generator/dist/generate.js:203:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/workspace/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)


 FAIL  __tests__/issues/36.test.ts (8.099 s)
  ● many-to-many.prisma

    Command failed: npx prisma generate --schema ./prisma/36.prisma
    Error: 
    ✔ Generated Prisma Client (3.6.0 | library) to ./node_modules/@prisma/client in 63ms

    Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-m3S4d2/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/36.png -t forest -c /tmp/prisma-erd-m3S4d2/config.json

      201 |             }
      202 |         }
    > 203 |         child_process.execSync(`${mermaidCliNodePath} -i ${tempMermaidFile} -o ${output} -t ${theme} -c ${tempConfigFile}`, {
          |                       ^
      204 |             stdio: 'ignore',
      205 |         });
      206 |         // throw error if file was not created

      at Object.exports.default [as onGenerate] (dist/generate.js:203:23)
      at async LineStream.<anonymous> (node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
      at Object.<anonymous> (__tests__/issues/36.test.ts:7:19)

Error: 
✔ Generated Prisma Client (3.6.0 | library) to ./node_modules/@prisma/client in 132ms

Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-fGfuXi/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/Mappings.svg -t forest -c /tmp/prisma-erd-fGfuXi/config.json
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at Object.exports.default [as onGenerate] (/workspace/prisma-erd-generator/dist/generate.js:203:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/workspace/prisma-erd-generator/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)


 FAIL  __tests__/map.test.ts (8.674 s)
  ● map e2e

    Command failed: npx prisma generate --schema ./prisma/mappings.prisma
    Error: 
    ✔ Generated Prisma Client (3.6.0 | library) to ./node_modules/@prisma/client in 132ms

    Error: Command failed: /workspace/prisma-erd-generator/node_modules/.bin/mmdc -i /tmp/prisma-erd-fGfuXi/prisma.mmd -o /workspace/prisma-erd-generator/__tests__/Mappings.svg -t forest -c /tmp/prisma-erd-fGfuXi/config.json

      201 |             }
      202 |         }
    > 203 |         child_process.execSync(`${mermaidCliNodePath} -i ${tempMermaidFile} -o ${output} -t ${theme} -c ${tempConfigFile}`, {
          |                       ^
      204 |             stdio: 'ignore',
      205 |         });
      206 |         // throw error if file was not created

      at Object.exports.default [as onGenerate] (dist/generate.js:203:23)
      at async LineStream.<anonymous> (node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)
      at Object.<anonymous> (__tests__/map.test.ts:88:19)

Not sure what I am doing wrong.

Not generating ER Diagram

Already tried:

  • npm i -D @mermaid-js/mermaid-cli
  • npm i -D prisma-erd-generator@latest
  • triple check the schema.prisma

Error: Issue generating ER Diagram. Expected ~\ERD.svg to be created at exports.default [as onGenerate] (~\node_modules\prisma-erd-generator\dist\generate.js:269:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async LineStream.<anonymous> (~\node_modules\@prisma\generator-helper\dist\generatorHandler.js:36:24)

Any ideas?

Schema generation fails under WSL

I'm interested in using this for a project, but I'm unable to get it to generate even a basic diagram.

UPDATE: It turns out the issue is that puppeteer, which is a dependency of mermaid, doesn't work under WSL. There's no way you would be able to fix this.

Error: could not parse datamodel

I have a recent schema (39 models) created via db pull with 3.4.2. Unfortunately no svg is created and with DEBUG=* I see this error message:

  prisma:GeneratorProcess Error: could not parse datamodel +463ms
  prisma:GeneratorProcess     at Object.exports.default [as onGenerate] (C:\Users\Jan\Documents\throwaway\cloud-api\node_modules\prisma-erd-generator\dist\generate.js:146:19) +1ms
  prisma:GeneratorProcess     at processTicksAndRejections (internal/process/task_queues.js:95:5) +0ms
  prisma:GeneratorProcess     at async LineStream.<anonymous> (C:\Users\Jan\Documents\throwaway\cloud-api\node_modules\@prisma\generator-helper\dist\generatorHandler.js:36:24) +1ms

What is the best way to debug this?

(I unfortunately can not share the schema here)

Table and column name mapping bug

Hi, I've encountered a weird bug with how I'm using mappings and prisma-erd-generator. Everything in Prisma generates the way I'd expect but prisma-erd-generator generates a svg for me with names I'm not expecting. Here's some example that recreates the issue:
prisma.schema:

generator client {
  provider      = "prisma-client-js"
  output        = "client"
}

generator erd {
  provider = "prisma-erd-generator"
  output = "./erd.svg"
  theme = "default"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Store {
  @@map("stores")

  id                String            @map("store_id") @id @default(uuid())

  employees         Employee[]
  customers         Customer[]
}

model Employee {
  @@map("employees")

  id                String            @map("employee_id") @id @default(uuid())
  storeId           String            @map("store_id")

  store             Store             @relation(fields: [storeId], references: [id])
  orders            Order[]
}

model Customer {
  @@map("customers")

  id                String            @map("customer_id") @id @default(uuid())
  storeId           String            @map("store_id")

  store             Store             @relation(fields: [storeId], references: [id])
  orders            Order[]
}

model Order {
  @@map("orders")

  id                String            @map("order_id") @id @default(uuid()) 
  employeeId        String            @map("employee_id")
  customerId        String            @map("customer_id")

  employee          Employee          @relation(fields: [employeeId], references: [id])
  customer          Customer          @relation(fields: [customerId], references: [id])
}

SVG generated by prisma-erd-generator:
erd

What I expecting to see in the SVG was: the PK for the orders table should be order_id, PK for the employees table should be employee_id, and PK for customers should be customer_id.

Am I doing something wrong?

Versioning improvements

Right now I'm manually versioning and using a bit of standard-version and npm publish to push out new versions. As you can see, it's not going well and I'll need to peek around and see what others are doing but I'd like to improve this. Any suggestions for improvement are welcome!

Dist Folder Issue

Description

Looking for debugging this library, noticed something strange. The dist folder contains different outputs and duplicates files.

dist/generate.js 180 lines
dist/src/generate.js 159 lines

Looks like something was caused by a tsconfig change at some point.

image

Improvement ideas:

  • Clean dist folder before running build
  • Exclude src folder in .npmignore

No m:n relations rendered

I have a Prisma Schema that is based on a Prisma 1 schema, and only has m:n relations. Is it intentional that m:n relations are not rendered at all?

env var to not generate

It would be a good idea for my use case and maybe others to have a way, with env var for example to cancel the generation in CI pipeline

thanks

Not working for MongoDB

When using mongodb, the erd doesn't create any relationships. Is it possible to use the relationships from the schema file rather than the SQL foreign keys?

Replace Mermaid

Most of the issues related to this repository have been related to getting mermaid cli to generate a file. Variables that I've noticed so far are

There are also ideas for extension such as

  • Large schema(s) not filling space in a smart way
  • Limited color schemes

This issue is to discuss what we would need out of a replacement. If there is enough interest maybe we could get this started

Column names with spaces make ERD invalid

In #64 (comment) I had one schema that did not work for some reason. Here is the Mermaid code for it:

erDiagram

  companies {
      String z_id
    String alias_list
    String blog_feed_url
    String blog_url
    String category_code
    String created_at
    String crunchbase_url
    Int deadpooled_day
    Int deadpooled_month
    String deadpooled_url
    Int deadpooled_year
    String description
    String email_address
    Int founded_day
    Int founded_month
    Int founded_year
    String homepage_url
    String end station name
    Int number_of_employees
    String overview
    String permalink
    String phone_number
    String tag_list
    String total_money_raised
    String twitter_username
    String updated_at
    }
  

  grades {
      String z_id
    Float class_id
    Float student_id
    }
  

  inspections {
      String z_id
    String business_name
    Int certificate_number
    String date
    String id
    String result
    String sector
    }
  

  posts {
      String z_id
    String author
    String body
    DateTime date
    String permalink
    String tags
    String title
    }
  

  routes {
      String z_id
    Int airplane
    String codeshare
    String dst_airport
    String src_airport
    Int stops
    }
  

  trips {
      String z_id
    Int bikeid
    Int birth year
    Int end station id
    String end station name
    Int start station id
    String start station name
    DateTime start time
    DateTime stop time
    Int tripduration
    }
  

  zips {
      String z_id
    String city
    Int pop
    String state
    String zip
    }
  

  CompaniesAcquisition {
      Int acquired_day
    Int acquired_month
    Int acquired_year
    Int price_amount
    String price_currency_code
    String source_description
    String source_url
    String term_code
    }
  

  CompaniesAcquisitionAcquiringCompany {
      String name
    String permalink
    }
  

  CompaniesAcquisitions {
      Int acquired_day
    Int acquired_month
    Int acquired_year
    Int price_amount
    String price_currency_code
    String source_description
    String source_url
    String term_code
    }
  

  CompaniesAcquisitionsCompany {
      String name
    String permalink
    }
  

  CompaniesCompetitions {
  
    }
  

  CompaniesCompetitionsCompetitor {
      String name
    String permalink
    }
  

  CompaniesExternalLinks {
      String external_url
    String title
    }
  

  CompaniesFundingRounds {
      Int funded_day
    Int funded_month
    Int funded_year
    Int id
    Int raised_amount
    String raised_currency_code
    String round_code
    String source_description
    String source_url
    }
  

  CompaniesFundingRoundsInvestments {
  
    }
  

  CompaniesFundingRoundsInvestmentsCompany {
      String name
    String permalink
    }
  

  CompaniesFundingRoundsInvestmentsFinancialOrg {
      String name
    String permalink
    }
  

  CompaniesFundingRoundsInvestmentsPerson {
      String first_name
    String last_name
    String permalink
    }
  

  CompaniesImage {
      Json attribution
    Int available_sizes
    }
  

  CompaniesInvestments {
  
    }
  

  CompaniesInvestmentsFundingRound {
      Int funded_day
    Int funded_month
    Int funded_year
    Int raised_amount
    String raised_currency_code
    String round_code
    String source_description
    String source_url
    }
  

  CompaniesInvestmentsFundingRoundCompany {
      String name
    String permalink
    }
  

  CompaniesIpo {
      Int pub_day
    Int pub_month
    Int pub_year
    String stock_symbol
    BigInt valuation_amount
    String valuation_currency_code
    }
  

  CompaniesMilestones {
      String description
    Int id
    String source_description
    String source_text
    String source_url
    String stoneable_type
    Json stoned_acquirer
    Int stoned_day
    Int stoned_month
    Json stoned_value
    Json stoned_value_type
    Int stoned_year
    }
  

  CompaniesMilestonesStoneable {
      String name
    String permalink
    }
  

  CompaniesOffices {
      String address1
    String address2
    String city
    String country_code
    String description
    Float latitude
    Float longitude
    String state_code
    String zip_code
    }
  

  CompaniesPartners {
      String homepage_url
    String link_1_name
    String link_1_url
    String link_2_name
    String link_2_url
    Json link_3_name
    Json link_3_url
    String partner_name
    }
  

  CompaniesProducts {
      String name
    String permalink
    }
  

  CompaniesProviderships {
      Boolean is_past
    String title
    }
  

  CompaniesProvidershipsProvider {
      String name
    String permalink
    }
  

  CompaniesRelationships {
      Boolean is_past
    String title
    }
  

  CompaniesRelationshipsPerson {
      String first_name
    String last_name
    String permalink
    }
  

  CompaniesScreenshots {
      Json attribution
    Int available_sizes
    }
  

  CompaniesVideoEmbeds {
      String description
    String embed_code
    }
  

  GradesScores {
      Float score
    String type
    }
  

  InspectionsAddress {
      String city
    Int number
    String street
    Int zip
    }
  

  PostsComments {
      String author
    String body
    String email
    }
  

  RoutesAirline {
      String alias
    String iata
    Int id
    String name
    }
  

  TripsEndStationLocation {
      Float coordinates
    String type
    }
  

  TripsStartStationLocation {
      Float coordinates
    String type
    }
  

  ZipsLoc {
      Float x
    Float y
    }
  
    companies o|--|| CompaniesAcquisition : "acquisition"
    companies o|--|| CompaniesAcquisitions : "acquisitions"
    companies }o--|| CompaniesCompetitions : "competitions"
    companies }o--|| CompaniesExternalLinks : "external_links"
    companies o|--|| CompaniesFundingRounds : "funding_rounds"
    companies o|--|| CompaniesImage : "image"
    companies }o--|| CompaniesInvestments : "investments"
    companies o|--|| CompaniesIpo : "ipo"
    companies }o--|| CompaniesMilestones : "milestones"
    companies o|--|| CompaniesOffices : "offices"
    companies }o--|| CompaniesPartners : "partners"
    companies }o--|| CompaniesProducts : "products"
    companies o|--|| CompaniesProviderships : "providerships"
    companies o|--|| CompaniesRelationships : "relationships"
    companies o|--|| CompaniesScreenshots : "screenshots"
    companies }o--|| CompaniesVideoEmbeds : "video_embeds"
    grades }o--|| GradesScores : "scores"
    inspections ||--|| InspectionsAddress : "address"
    posts }o--|| PostsComments : "comments"
    routes ||--|| RoutesAirline : "airline"
    trips o{--|| TripsEndStationLocation : "end station location"
    trips o{--|| TripsStartStationLocation : "start station location"
    zips ||--|| ZipsLoc : "end station location"
    CompaniesAcquisition ||--|| CompaniesAcquisitionAcquiringCompany : "acquiring_company"
    CompaniesAcquisitions ||--|| CompaniesAcquisitionsCompany : "company"
    CompaniesCompetitions ||--|| CompaniesCompetitionsCompetitor : "competitor"
    CompaniesFundingRounds o|--|| CompaniesFundingRoundsInvestments : "investments"
    CompaniesFundingRoundsInvestments |o--|| CompaniesFundingRoundsInvestmentsCompany : "company"
    CompaniesFundingRoundsInvestments |o--|| CompaniesFundingRoundsInvestmentsFinancialOrg : "financial_org"
    CompaniesFundingRoundsInvestments |o--|| CompaniesFundingRoundsInvestmentsPerson : "person"
    CompaniesInvestments ||--|| CompaniesInvestmentsFundingRound : "funding_round"
    CompaniesInvestmentsFundingRound ||--|| CompaniesInvestmentsFundingRoundCompany : "company"
    CompaniesMilestones ||--|| CompaniesMilestonesStoneable : "stoneable"
    CompaniesProviderships ||--|| CompaniesProvidershipsProvider : "provider"
    CompaniesRelationships ||--|| CompaniesRelationshipsPerson : "person"

Turns out that some of the "tables" have invalid (for Mermaid) field names with spaces:

trips {
    String z_id
    Int bikeid
    Int birth year
    Int end station id
    String end station name
    Int start station id
    String start station name
    DateTime start time
    DateTime stop time
    Int tripduration
}

We either need to replace these spaces, or use the non mapped Prisma field name (which can not contains spaces) here instead.

I can not create ER image...

y-koyamatsu@koyamatsuyukinoMacBook-Pro prisma % npx prisma generate

Environment variables loaded from ../.env
Prisma schema loaded from schema.prisma
Error: 
Error: Command failed: ../../ER図_v2'/node_modules/.bin/mmdc -i /var/folders/sw/5cfrfxkx6lj1z_d1ph0hrvpc0000gn/T/prisma-erd-u7WZMn/prisma.mmd -o /Users/y-koyamatsu/Desktop/KMJ/ER図_v2'/ERD.svg -t forest -c /var/folders/sw/5cfrfxkx6lj1z_d1ph0hrvpc0000gn/T/prisma-erd-u7WZMn/config.json
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at Object.exports.default [as onGenerate] (/Users/y-koyamatsu/Desktop/KMJ/ER図_v2'/node_modules/prisma-erd-generator/dist/generate.js:197:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async LineStream.<anonymous> (/Users/y-koyamatsu/Desktop/KMJ/ER図_v2'/node_modules/@prisma/generator-helper/dist/generatorHandler.js:36:24)

I got above error.... How I can do to slove this???

  "dependencies": {
    "@prisma/client": "^3.7.0",
    "mermaid": "^8.13.10",
    "prisma-erd-generator": "^0.9.0"
  }

No output generated

I've looked through all the other topical issues and it seems even with the latest version I still cannot get it to produce any output, despite saying it completed just fine :(

OS: MacOS 12.0.1
package version: 0.6.1

Schema


generator client {
  provider = "prisma-client-js"
}

generator erd {
  provider = "prisma-erd-generator"
  output   = "ERD.png"
}

generator nestgraphql {
  provider               = "node ../../../node_modules/prisma-nestjs-graphql"
  output                 = "../src/@generated/"
  reExport               = Single
  fields_Validator_from  = "class-validator"
  fields_Validator_input = true
}

datasource db {
  provider = "postgresql"
  url   = env("DATABASE_URL")
}

model User {
  /// @validator.IsUUID(all)
  id        String   @id @default(uuid()) @db.Uuid
  /// @Validator.IsEmail()
  email     String   @unique
  /// @Validator.Length(8, 64)
  password  String
  /// @Validator.IsJSON()
  roles     Json[]
  profile   Profile?
  /// @HideField({ output: false, input: true })
  createdAt DateTime @default(now())
  /// @HideField({ output: false, input: true })
  updatedAt DateTime @default(now())
}

model Profile {
  id        String @id @default(uuid()) @db.Uuid
  user      User   @relation(fields: [userId], references: [id])
  userId    String @unique @db.Uuid
  firstName String
  lastName  String
}

Console log says everything is fine

✔ Generated Entity-relationship-diagram to ./prisma/ERD.png in 621ms

But no diagram is produced.

Make ERD diagram more user friendly

Right now the diagrams are looking good. Nevertheless, I think they would be easier to understand with the following changes:
image

What do you think?
I can try to make a PR for that if you like it

Option to skip intermediate tables

For many-to-many relationships, in SQL we need an intermediate table. But it seems to clutter the ERD. Can we have an option to omit it, and instead draw a many-to-many directly between the two tables? I assume the intermediate model will need a meta flag for this.

@ignored fields should still be diagrammed

I routinely @ignore the sides of a relationship I'll never traverse since my generated type file is already over 40K lines with only a dozen tables. For example,

model User {
   id           Int      @id @default(autoincrement()) @db.UnsignedInt
   name         String
   type         UserType @relation(fields: [typeId], references: [id])
   typeId       Int      @db.UnsignedTinyInt
}

model UserType {
   id    Int    @id @db.UnsignedTinyInt
   name  String
   users User[] @ignore // never need this
}

If I do this, however, the relationship disappears from the diagram. I would like the option to include all relations even if one side is ignored for the purpose of the generated types.

I will look into this and see if I can come up with a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.