database-modeling-markdown README
The Latest Version: 2.0.2
Features
Please name your markdown files with extension .db.md .
Insert template into your markdown file
Support Databases:
- DB2
- MariaDB
- MS SQL Server
- MySQL
- Oracle Database
- PostgreSQL
- SQLite
Command: Database Modeling Markdown: Insert Template Content
Command: Database Modeling Markdown: Generate Create Tables SQL
Command: Database Modeling Markdown: Generate Create Tables If Not Exists SQL
Command: Database Modeling Markdown: Generate Drop then Create Tables SQL
Command: Database Modeling Markdown: Generate Drop Tables SQL
Command: Database Modeling Markdown: Generate a Json File
Command: Database Modeling Markdown: Generate an Index Markdown File
generate index.md for a database model.
Command: Database Modeling Markdown: Generate Upgrade SQL
(mariadb/mysql only)
Command: Database Modeling Markdown: Import From Database
(mariadb/mysql only)
How to Use
Step: Edit your database definition markdown files
- Create a markdown file with extension
.db.md .
- Open the file
- Press
Ctrl + Shift + P , and run Database Modeling Markdown: Insert Template Content
- Provide your table definitions. e.g.
# Table: departments
## `Table`
| `Name` | `Comment` | `Character Set` | `Collation` | `Engine` |
| ----------- | --------------------- | --------------- | ------------------ | -------- |
| departments | The department table. | utf8mb4 | utf8mb4_general_ci | InnoDB |
## `Primary Key`
| `Columns` |
| ------------ |
| DepartmentID |
## `Indexes`
## `Foreign Keys`
| `Columns` | `Ref Table` | `Ref Columns` | `Options` |
| --------- | ----------- | ------------- | --------- |
| ManagerID | employees | EmployeeID | |
| ParentID | departments | DepartmentID | |
## `Columns`
| `Label` | `Name` | `Type` | `Nullable` | `Default` | `Comment` |
| --------------- | -------------- | -------------------------------------- | ---------- | ------------------- | -------------------- |
| Department ID | DepartmentID | int auto_increment | `No` | | Department ID |
| Department Name | DepartmentName | varchar(50) | `No` | | Department Name |
| Parent ID | ParentID | int | `Yes` | | Parent Department |
| Manager ID | ManagerID | int | `Yes` | | Manager |
| Created By | CreatedBy | varchar(255) | `No` | '' | Created By User Name |
| Create Time | CreateTime | datetime | `No` | current_timestamp() | Created Time |
| Update By | UpdateBy | varchar(255) | `No` | '' | Updated By User Name |
| Update Time | UpdateTime | datetime on update current_timestamp() | `No` | current_timestamp() | Updated Time |
Step: Generate Scripts
- Provide workspace settings, for example:
{
"database-modeling-markdown.default.commanad": "toCreateTableIfNotExistsSql",
"database-modeling-markdown.database": "mysql",
"database-modeling-markdown.source.folder": "./data/mysql/tables",
"database-modeling-markdown.target.path": "./createTables.sql",
"database-modeling-markdown.previous.version.folder": "./data/mysql/tables/v1"
}
- Press
Ctrl + Shift + P , and run Database Modeling Markdown: Generate Create Tables If Not Exists SQL
- Find
./createTables.sql .
Rules
- Must use markdown inline code for type boolean/number/null, e.g.
true , false , Yes , No , null , 100 , 1.23 .
- You may use inline code for 'section names', 'list item names', or table headers, e.g. #
Primary Key
Extension Settings
This extension contributes the following settings:
database-modeling-markdown.database : the target database type, default: mysql .
Support: [
"db2",
"mariadb",
"mssql",
"mysql",
"oracle",
"postgresql",
"sqlite" ]
database-modeling-markdown.default.commanad : the target database type, default: toCreateTableIfNotExistsSql .
Support: [
"toCreateTableIfNotExistsSql",
"toCreateTableSql",
"toDropTableSql",
"toDropThenCreateTableSql",
"toJson",
"toUpgradeSql" ]
database-modeling-markdown.file.extension : the table defintion markdown file extension, default: .db.md .
database-modeling-markdown.source.folder : The markdown file directory of the database model. example: ./tables .
database-modeling-markdown.target.path : the generated file path, default: ./createTables.sql .
database-modeling-markdown.previous.version.folder : The markdown file directory of the previous database version. example: ./tables/v1 .
Enjoy!
| |