tbls
tbls
is a tool for document a database, written in Go.
The key of Features of tbls
are:
- Single binary
- Document in GitHub Friendly Markdown format
- CI friendly
Usage | Sample | Integration with CI tools | Installation | Database Support
Usage
$ 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
version print tbls version
Flags:
-h, --help help for tbls
Use "tbls [command] --help" for more information about a command.
Document a database schema
tbls doc
analyzes a database and generate document in GitHub Friendly Markdown format.
$ tbls doc postgres://user:pass@hostname:5432/dbname ./dbdoc
Sample document and schema.
Diff database schema and document
tbls diff
shows the difference between database schema and generated document.
$ tbls diff postgres://user:pass@hostname:5432/dbname ./dbdoc
- Commit document using
tbls doc --sort
.
- Check document updates using
tbls diff --sort
Set following code to your-ci-config.yml
.
DIFF=`tbls diff pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable ./sample --sort` && if [ ! -z "$DIFF" ]; then echo "document does not match database." >&2 ; echo tbls diff pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable ./sample --sort; exit 1; fi
Makefile sample is following
doc: ## Document database schema
tbls doc postgres://postgres:pgpass@localhost:55432/testdb?sslmode=disable ./doc --sort
testdoc: ## Test database schema document
$(eval DIFF := $(shell tbls diff postgres://postgres:pgpass@localhost:55432/testdb?sslmode=disable ./doc --sort))
@test -z "$(DIFF)" || (echo "document does not match database." && postgres://postgres:pgpass@localhost:55432/testdb?sslmode=disable ./doc --sort && exit 1)
Installation
$ go get github.com/k1LoW/tbls
Database Support