tbls is a CI-Friendly tool for document a database, written in Go.
Key features of tbls are:
- Single binary
- Document in GitHub Friendly Markdown format
- CI-Friendly
Usage | Sample | Integration with CI tools | Installation | Database Support
$ tbls
tbls is a tool for document a database, written in Go.
Usage:
tbls [command]
Available Commands:
diff diff database and document
doc document a database
help Help about any command
lint check database document
out analyzes a database and output
version print tbls version
Flags:
-h, --help help for tbls
Use "tbls [command] --help" for more information about a command.tbls doc analyzes a database and generate document in GitHub Friendly Markdown format.
$ tbls doc postgres://user:pass@hostname:5432/dbname ./dbdocIf you can use Graphviz dot command, tbls doc generate ER diagram images at the same time.
NOTICE: If you are using a symbol such as
#<in database password, URL-encode the password
tbls diff shows the difference between database schema and generated document.
$ tbls diff postgres://user:pass@hostname:5432/dbname ./dbdocNotice: tbls diff shows the difference Markdown documents only.
- Commit document using
tbls doc. - Check document updates using
tbls diff
Set following code to your-ci-config.yml.
$ tbls diff postgres://user:pass@localhost:5432/testdb?sslmode=disable ./dbdocMakefile sample is following
doc: ## Document database schema
tbls doc postgres://user:pass@localhost:5432/testdb?sslmode=disable ./dbdoc
testdoc: ## Test database schema document
tbls diff postgres://user:pass@localhost:5432/testdb?sslmode=disable ./dbdocTips: If the order of the columns does not match, you can use the --sort option.
$ tbls doc my://root:mypass@localhost:33306/testdb sample/mysqlPut .tbls.yml on execute directory or specify with the --config option.
YAML format is follows
---
dsn: my://root:mypass@localhost:33306/testdb
docPath: sample/mysql---
dsn: my://${MYSQL_USER}:${MYSQL_PASSWORD}@localhost:33306/${MYSQL_DATABASE}
docPath: sample/mysql$ env TBLS_DSN=my://root:mypass@localhost:33306/testdb TBLS_DOC_PATH=sample/mysql tbls docTo add additional data to the schema, add settings to .tbls.yml or --config like YAML file (relations, comments)
To check database document, add settings to .tbls.yml or --config like YAML file (lint)
$ go get github.com/k1LoW/tblsor
$ brew install k1LoW/tap/tbls- PostgreSQL
- MySQL
- SQLite