Skip to content

Support more dbml features#17

Merged
imakecodes merged 9 commits into
makecodes:mainfrom
mhindery:main
Sep 26, 2024
Merged

Support more dbml features#17
imakecodes merged 9 commits into
makecodes:mainfrom
mhindery:main

Conversation

@mhindery

@mhindery mhindery commented Aug 18, 2024

Copy link
Copy Markdown
Contributor

Hi, I'm using django and dbml together, and I've made several changes in order to improve the dbml being generated:

  • Add table indices to the dbml (either defined on the field itself, or via the Meta attribute of a class)
  • Add enums to the dbml when model fields have choices defined on them.
  • Add the database type to the dbml based on the db settings of django.
  • Alphabetically sort the output entries (tables, enums, table groups, indices), so they are easier to navigate on e.g. dbdocs
  • Add an argument 'output_file' to output the result to a file instead of to stdout
  • Skip the autogenerated many-to-many table in case an explicit through model is defined on a relation (previously it would include the unused default one)
  • Include the app name in the table name for a model. Previously this wasn't the case, and models with the same name from different apps would overwrite each other.
  • Add the db table name in the note of each table, unless the table names are used for the models already.
  • Some smaller changes, added comments, some cleanup, some type annotations
  • Support some more field types to output (I'm using the Postgres-specific ArrayField myself which is a list of predefined choices, and with these changes this is nicely outputted to dbml) and extracted it into a method so people can subclass it if desired.

@imakecodes

Copy link
Copy Markdown
Member

Hi @mhindery I'll take a look this weekend, thank you so much for this pull request, its gold!
I also need sometime to add unit tests

@sonarqubecloud

Copy link
Copy Markdown

@imakecodes imakecodes merged commit 9236add into makecodes:main Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants