holistics / dbml

Database Markup Language (DBML), designed to define and document database structures
https://dbml.org
Apache License 2.0
2.8k stars 166 forks source link

Add support for imports and exports #468

Open BasileusErwin opened 11 months ago

BasileusErwin commented 11 months ago

Hi,

I'd like to propose an enhancement to the DBML language that would ease the management of large and complex schemas, especially in projects that progress through multiple phases. I have two potential approaches I'd like to present.

Background:

At my job, we're in an advanced phase of a project using DBML, with many tables and enums already created. The need to manage and maintain code between project phases is growing, and I see an opportunity to improve modularity and code reuse with import and export support.

Proposal 1: Direct support for imports and exports

  1. Imports: Introduce new syntax to import other DBML files. For instance:
    import 'path/to/other/file.dbml'
  2. Exports: Allow specifying which elements from the current file should be exported.
    export Table User {

Proposal 2: Preprocessing system akin to C's "include"

Instead of handling imports and exports directly within the language, we could introduce a preprocessing system. Developers would use an "include" syntax to stitch together various DBML files into one during a preprocessing phase. This approach would hide the modularity from the DBML engine, which would see a single, unified file.

For example:

include "path/to/other/file.dbml"

Common Benefits:

Potential Challenges:

I hope you find these proposals of interest. I am willing to collaborate on the implementation and clarify any questions.

Best regards

asule90 commented 9 months ago

i think its the same as https://github.com/holistics/dbml/issues/125

BasileusErwin commented 9 months ago

Yes, I saw that, but since the last update was in 2021, I wanted to get this topic moved again.