Integration with version control system like Github & Gitlab

dbdiagram has a great potential for the philosophy “code as document”, the way I see it we have below use cases

1. Display diagram in markdown file with embedded link

Example we have README.md like below

# Feature
Some description

# ERD
<iframe width="560" height="315" src='https://dbdiagram.io/embed/abc'> </iframe>

2. Display diagram in markdown file with reference link to file in repo

Example we have README.md like below

# Feature
Some description

# ERD
[erd](docs/erd.dbml)

3. Sync dbdiagram with git repo

It would be great if we can setup a git repo as a backend to manage saved diagram, by doing this we have the power of a full version control system
With this it would be easier to manage and refer the diagram

2 Likes

Hi @minhpham,

Those are wonderful ideas !

I especially like the idea sync dbdiagram with git repo, certainly worth implementing. Could you elaborate more on how you would use dbdiagram if it’s backed by a version control system ?

Hi Duy,

I have sometime to draft up a more detail version comparing to previous suggestion

My current workflow

I store all the diagram in a git repo to work with my team (for code review and versoning stuff)

.
|_ docs
|  |_ db
|     |_ overall_erd.dbml
|     |_ full_erd.dbml
|     |_ *.dbml
|_ REAME.md

But git cannot display the diagram, therefore I have to clone all the diagram to dbdiagram app

My diagrams
|_ overall_erd.dbml
|_ full_erd.dbml
|_ *.dbml

Other team member can checkout the git repo and again clone the necessary diagram to their dbdiagram app

Draw backs

Multiple tools are required to track the changes

If I want to update the diagram, I have to do either of below

  • update in dbdiagram app copy to git file
  • update git file and copy to dbdiagram app

It’s not easy to collaborate with the team using dbdiagram app

It’s reasonable if team collaboration is the main goal for the future and has a potential to become a business model
but I wonder if there’s a way to adapt with some other platform out there (github or gitlab) for community version perhaps

Only the owner of the diagram can edit

Because of this dbdiagram app cannot be used as a serious knowledge base (wiki) for team. That’s why I have to use git

No version control in dbdiagram app

Diagram is code based therefore each update has to be reviewed and controlled. That’s why I have to use git

Suggestions

Below are very opinionated suggestions from my perspective but I think it’s worth mentioning

1. Integrate with git system

a. Ability to display dbml files or embedded dbml block code in markdown

Gitlab & Plantuml has achieved similar workflow: https://docs.gitlab.com/ee/administration/integration/plantuml.html

Cons

  • Need to setup a separated server for rendering

2. Dbdiagram app

a. Import dbml from git repo or file server/local folder

All dbml files will be scanned and diagrams will be automatically created for each dbml files

Example when import a git repo like this

.
|_ docs
|  |_ db
|     |_ overall_erd.dbml
|     |_ full_erd.dbml
|     |_ *.dbml
|_ REAME.md

We will have below diagrams

My diagrams
|_ overall_erd.dbml
|_ full_erd.dbml
|_ *.dbml

Existed diagrams will be overriden (with a warning of course) on each import

Cons

  • just a convenient method to import multiple dbml files still far from a robust system for team collaboration

b. Use git as a backend to store diagrams

All dbml files will be scanned and diagrams will be automatically created for each dbml files (like above demonstration)

  • When files in git system are updated, diagram should also be be updated
    • This is the important feature of this workflow
  • When diagrams are updated, git files should also be updated
    • In my opinion, this is a nice to have feature
    • I’m ok if diagram UI is just read only when link with git system

Cons

  • Though we don’t need to setup a separate server for rendering like other suggestion, we have to use dbdiagram app instead of just using git UI
1 Like

Hi Minh,

Thanks for those great ideas again !

Actually, we did come up with several ideas for team collaboration, some are the same as you suggested. However, we’re still on the way of deciding which implementation best suits users’ needs. Your detailed analysis absolutely helps us on finalizing and consolidating the idea.

Will keep you updated when any progress has been made !

This is a important functionality, and thread author has covered all of the core requirements.

Bruno, and API management tool, is an excellent example of local development with git-based VCS. Something similar would increase our day-to-day usage of dbdiagram. It is an excellent, well-designed tool.