holistics / holistics/dbml

Use CLI to generate DDL sql to apply structure update from two versions of a given DBML file

Open
#175 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.7k
Forks
233
Avg merge
1d 23h
Merged PRs (30d)
4

Description

If we have DBML in source control, and we apply a change, it goes from V1 to V2, have a cli command which enables generating the DDL alter statements to bring any existing databases on V1 up to V2.

For example:

Users v1
```dbml
// path: /dbmodel/v1/users.dbml

Table users as U {
id int [pk, increment] // auto-increment
full_name varchar
created_at timestamp
country_code int
}
```

Users v2
```dbml
// path: /dbmodel/v2/users.dbml

Table users as U {
id int [pk, increment] // auto-increment
full_name varchar
middle_name varchar
created_at timestamp
country_code int
}
```

CLI Command
```bash
dbml2sqlmigrate --mysql -o /dbmodel/ddlv1tov2/ /dbmodel/v1/ /dbmodel/v2/
```

Output

```sql
# /dbmodel/ddlv1tov2/users.sql

ALTER TABLE `users`
ADD COLUMN `middle_name` varchar(255) AFTER `full_name`;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.