tbls

command module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2018 License: MIT Imports: 4 Imported by: 0

README

tbls Build Status GitHub release codecov

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

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
  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.
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

If you can use Graphviz dot command, tbls doc generate ER diagram images at the same time.

Sample document and schema.

NOTICE: If you are using a symbol such as # < in database password, URL-encode the password

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

Notice: tbls diff shows the difference Markdown documents only.

Integration with CI tools

  1. Commit document using tbls doc.
  2. Check document updates using tbls diff

Set following code to your-ci-config.yml.

$ tbls diff postgres://user:pass@localhost:5432/testdb?sslmode=disable ./dbdoc

Makefile 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 ./dbdoc

Tips: If the order of the columns does not match, you can use the --sort option.

How to specify DSN and Document path

1. Command arguments
$ tbls doc my://root:mypass@localhost:33306/testdb sample/mysql
2. Use .tbls.yml or set --config option

Put .tbls.yml on execute directory or specify with the --config option.

YAML format is follows

---
dsn: my://root:mypass@localhost:33306/testdb
dataPath: sample/mysql
3. Envirionment
$ env TBLS_DSN=my://root:mypass@localhost:33306/testdb TBLS_DOC_PATH=sample/mysql tbls doc

Add additional data (relations, comments) to schema

To add additional data to the schema, specify the YAML file with the --config option as follows

$ tbls doc mysql://user:pass@hostname:3306/dbname --config path/to/additional_data.yml ./dbdoc

Installation

$ go get github.com/k1LoW/tbls

or

$ brew install k1LoW/tbls/tbls

Database Support

  • PostgreSQL
  • MySQL
  • SQLite

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
dot
md

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL