Schema Migration Tool Support for Cockroach

Hey y’all!

Just wanted to let everyone know I finished getting CockroachDB added to the Migrate schema migration library & CLI. Similar to Flyway or Liquibase, Migrate facilitates development by managing schema versions and the migrations up and down between them.

The project still isn’t on homebrew yet, so if you want to use it as a CLI, it’s best to build it from source for now (requires Go 1.7+). You can do so by running:

$ go get -u -d
$ go build -tags 'cockroachdb' -o /usr/local/bin/migrate

Once that’s done, you can use it to run schema migrations against a CockroachDB instance using any of the supported migration sources. For a simple filesystem based example of the migrations format, you can look at the cockroachdb/examples directory in the repo.

Note that to avoid conflicts with the postgres implementation in the library, the connect string uses the cockroach:// protocol prefix rather postgres://, which the library then substitutes during runtime.

As a concrete example, if your migrations existed in a directory at relative location ./migrations with database named bank and user with DDL grants named maxroach running on an insecure local cluster, you could apply all migrations up to the latest version by running:

$ migrate -path ./migrations -database 'cockroach://maxroach@localhost:26257/bank?sslmode=disable' up

Configuration options are shown in the Cockroach database package’s README.


Looks very useful, but can you add the docs linked from the README? This link works but has no content:

This has been updated now.