Docs: Commands: diff

Usage: skeema diff [<options>] [<environment>]

Compares the schemas on database instance(s) to the corresponding filesystem representation of them. The output is a series of DDL commands that, if run on the instance, would cause the instances' schemas to now match the definitions from the filesystem.

You may optionally pass an environment name as a CLI arg. This will affect which section of .skeema config files is used for processing. For example, running skeema diff staging will apply config directives from the [staging] section of config files, as well as any sectionless directives at the top of the file. If no environment name is supplied, the default is “production”.

The skeema diff command is equivalent to running skeema push with its dry-run option enabled.

An exit code of 0 will be returned if no differences were found; 1 if some differences were found; or 2+ if an error occurred.

DDL Generation Options

OptionDescription
alter-algorithmApply an ALGORITHM clause to all ALTER TABLEs
alter-lockApply a LOCK clause to all ALTER TABLEs
alter-validate-virtualApply a WITH VALIDATION clause to ALTER TABLEs affecting virtual columns
compare-metadataFor stored programs, detect changes to creation-time sql_mode or DB collation
exact-matchFollow *.sql table definitions exactly, even for differences with no functional impact
partitioningSpecify handling of partitioning status on the database side

External Tool Options

OptionDescription
alter-wrapperOutput ALTER TABLEs as shell commands rather than just raw DDL; see manual for template vars
alter-wrapper-min-sizeIgnore alter-wrapper for tables smaller than this size in bytes
ddl-wrapperLike alter-wrapper, but applies to all DDL types (CREATE, DROP, ALTER)

Linter Rule Options

OptionDescription
allow-auto-incList of allowed auto_increment column data types for lint-auto-inc
allow-charsetList of allowed character sets for lint-charset
allow-compressionList of allowed compression settings for lint-compression
allow-definerList of allowed routine definers for lint-definer
allow-engineList of allowed storage engines for lint-engine
lintCheck modified objects for problems before proceeding (enabled by default)
lint-auto-incOnly allow auto_increment column data types listed in allow-auto-inc
lint-charsetOnly allow character sets listed in allow-charset
lint-compressionOnly allow compression settings listed in allow-compression
lint-definerOnly allow routine definers listed in allow-definer
lint-display-widthOnly allow default display width for int types
lint-dupe-indexFlag redundant secondary indexes
lint-engineOnly allow storage engines listed in allow-engine
lint-has-fkFlag any use of foreign keys; intended for environments that restrict their presence
lint-has-floatFlag columns using FLOAT or DOUBLE data types
lint-has-routineFlag any use of stored procs or funcs; intended for environments that restrict their presence
lint-has-timeFlag columns using TIMESTAMP, DATETIME, or TIME data types
lint-pkFlag tables that lack a primary key
lint-zero-dateFlag DATE, DATETIME, and TIMESTAMP columns that have zero-date default values

Safety Options

OptionDescription
allow-unsafePermit generating ALTER or DROP operations that are potentially destructive
safe-below-sizeAlways permit generating destructive operations for tables below this size in bytes
verifyTest all generated ALTER statements on temp schema to verify correctness (enabled by default)

Sharding Options

OptionDescription
briefDon’t output DDL to STDOUT; instead output list of instances with at least one difference
concurrent-instancesPerform operations on this number of instances concurrently
first-onlyFor dirs mapping to multiple instances or schemas, just run against the first per dir

Workspace Options

OptionDescription
docker-cleanupWith workspace=docker, specifies how to clean up containers
temp-schemaName of temporary schema for intermediate operations, created and dropped each run
temp-schema-binlogControls whether temp schema DDL operations are replicated
temp-schema-threadsMax number of concurrent CREATE/DROP with workspace=temp-schema
workspaceSpecifies where to run intermediate operations

Global Options

OptionDescription
connect-optionsComma-separated session options to set upon connecting to each database instance
debugEnable debug logging
helpDisplay usage information for the specified command
host-wrapperExternal bin to shell out to for host lookup; see manual for template vars
ignore-schemaIgnore schemas that match regex
ignore-tableIgnore tables that match regex
my-cnfParse ~/.my.cnf for configuration (enabled by default)
passwordPassword for database user; omit value to prompt from TTY (default no password)
userUsername to connect to database host
versionDisplay program version