Schema management CLI for MySQL
Clone or download
evanelias Fix error from foreign key with same name as unique key
Within a single database schema, if a foreign key has the same name as a unique
index, all Skeema commands would fail with this error message:

    Error querying foreign key constraints: sql: Scan error on column index 6:
    unsupported Scan, storing driver.Value type <nil> into type *string

This occurred because an additional join clause is needed to de-dupe this
situation, as both types of constraints are present in MySQL's
information_schema.key_column_usage table.

The bug and its fix are both actually in github.com/skeema/tengo, so this commit
just updates the vendored dep. Test coverage is handled by
skeema/tengo@c9951fe#diff-ad27291d895bd1679307e9c94c251037

Fixes #46.
Latest commit c058cb9 Nov 12, 2018
Permalink
Failed to load latest commit information.
applier Options to use local Docker for temporary schema (#45) Nov 9, 2018
doc Options to use local Docker for temporary schema (#45) Nov 9, 2018
fs Options to use local Docker for temporary schema (#45) Nov 9, 2018
testdata Minor cleanups after reviewing the code in this branch Oct 29, 2018
util Options to use local Docker for temporary schema (#45) Nov 9, 2018
vendor Fix error from foreign key with same name as unique key Nov 12, 2018
workspace Options to use local Docker for temporary schema (#45) Nov 9, 2018
.gitignore travis CI: auto-goreleaser upon tagging Jul 11, 2018
.goreleaser.yml goreleaser: change archive and checksum filenames for future releases Jul 11, 2018
.travis.yml Travis: Add applier package to gofmt check Oct 26, 2018
Gopkg.lock Fix error from foreign key with same name as unique key Nov 12, 2018
Gopkg.toml Major internal refactor to use subpackages Oct 26, 2018
LICENSE Add skeleton README, along with NOTICE and LICENSE (Apache v2) Oct 18, 2016
NOTICE Docs: update supported database version/flavor list in requirements.md Jul 9, 2018
README.md Options to use local Docker for temporary schema (#45) Nov 9, 2018
cmd_add_env.go init, add-environment: persist more options if specified on CLI Oct 30, 2018
cmd_diff.go Major internal refactor to use subpackages Oct 26, 2018
cmd_init.go init, add-environment: persist more options if specified on CLI Oct 30, 2018
cmd_lint.go Options to use local Docker for temporary schema (#45) Nov 9, 2018
cmd_pull.go Options to use local Docker for temporary schema (#45) Nov 9, 2018
cmd_push.go Minor cleanups after reviewing the code in this branch Oct 29, 2018
exit.go Minor cleanups after reviewing the code in this branch Oct 29, 2018
exit_test.go Add integration test suite for extensive coverage May 25, 2018
log.go Major internal refactor to use subpackages Oct 26, 2018
skeema.go Fix error from foreign key with same name as unique key Nov 12, 2018
skeema_cmd_test.go Options to use local Docker for temporary schema (#45) Nov 9, 2018
skeema_test.go Options to use local Docker for temporary schema (#45) Nov 9, 2018

README.md

Skeema

build status code coverage latest release

Skeema is a tool for managing MySQL tables and schema changes in a declarative fashion using pure SQL. It provides a CLI tool allowing you to:

  • Export CREATE TABLE statements to the filesystem, for tracking in a repo (git, hg, svn, etc)
  • Diff changes in the schema repo against live DBs to automatically generate DDL
  • Manage multiple environments (e.g. dev, staging, prod) and keep them in sync with ease
  • Configure use of online schema change tools, such as pt-online-schema-change, for performing ALTERs
  • Convert non-online migrations from frameworks like Rails or Django into online schema changes in production

Skeema supports a pull-request-based workflow for schema change submission, review, and execution. This permits your team to manage schema changes in exactly the same way as you manage code changes.

Downloading

Pre-built skeema binaries for Linux and macOS can be downloaded from the releases page.

Compiling

Compiling from scratch requires the Go programming language toolchain, version 1.9 or higher.

To download, build from master, and install (or upgrade) Skeema, run:

go get -u github.com/skeema/skeema

Documentation

Status

Skeema is generally available, having reached the v1 release milestone in July 2018. Prior to that, it was in public beta since October 2016.

The skeema binary is supported on macOS and Linux. For now, it cannot be compiled on Windows.

Tagged releases are tested against the following databases, all running on Linux:

  • MySQL 5.5, 5.6, 5.7, 8.0
  • Percona Server 5.6, 5.7
  • MariaDB 10.1, 10.2, 10.3

Outside of a tagged release, every commit to the master branch is automatically tested against MySQL 5.6 and 5.7.

A few uncommon MySQL features -- such as partitioning, fulltext indexes, spatial types, virtual columns -- are not yet supported. Skeema is able to create or drop tables using these features, but not alter them. The output of skeema diff and skeema push clearly displays when this is the case. You may still make such alters directly/manually (outside of Skeema), and then update the corresponding CREATE TABLE files via skeema pull.

Credits

Created and maintained by @evanelias.

Additional contributions by:

License

Copyright 2018 Skeema LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.