tedivm / paracelsus

Visualize SQLAlchemy Databases using Mermaid or Dot Diagrams.
https://pypi.org/project/paracelsus/
MIT License
94 stars 10 forks source link

Use 'UK' and column comments #7

Closed justintime closed 7 months ago

justintime commented 7 months ago

Mermaid supports a key type of 'UK' for unique key, better to use that instead of adding a comment. Also, if the SQLAlchemy column has a comment assigned, we should add that to the Mermaid comment.

Here's the output for a table has has both a unique key and a comment in SQLAlchemy after the changes in this pull request:

  games {
    INTEGER id PK
    INTEGER away_team_id FK
    INTEGER home_team_id FK
    INTEGER league_id FK "nullable"
    INTEGER season_id FK
    INTEGER tracked_team_id FK
    INTEGER user_id FK
    INTEGER away_score
    VARCHAR(255) cuid UK "These are generated by clients and should be unique"
    DATE game_date
    INTEGER home_score
    VARCHAR(255) location
    BOOLEAN overtime
    BOOLEAN shootout
  }
tedivm commented 7 months ago

Can you fix the errors from testing? You should be able to pull down the branch and run make chores to do so.

justintime commented 7 months ago

Can you fix the errors from testing? You should be able to pull down the branch and run make chores to do so.

Thanks for the make hint. I was able to get make chores run cleanly on that last commit. I also added a column comment on FK's that describes which table the column refers to. On my ERD with ~ 20 tables and tons of FK's, it can be tedius to trace lines.

justintime commented 7 months ago

I can update the test suite as well, brb