Docs: Commands: lint

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

Checks for problems in filesystem representation of database objects. A set of linter rules are run against all objects. Each rule may be configured to generate an error, a warning, or be ignored entirely. Statements that contain invalid SQL, or otherwise return an error from the database, are always flagged as linter errors.

By default, this command also reformats CREATE statements to their canonical form, just like skeema format.

This command relies on accessing a database server to test the SQL DDL in a temporary location. See the workspace option for more information.

You may optionally pass an environment name as a command-line arg. This will affect which section of .skeema config files is used for linter configuration and workspace selection. For example, running skeema lint 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”.

An exit code of 0 will be returned if no errors or warnings were emitted and all files were already formatted properly; 1 if any warnings were emitted and/or some files were reformatted; or 2+ if any errors were emitted for any reason.

Format Options

OptionDescription
formatReformat SQL statements to match canonical SHOW CREATE (enabled by default; disable with skip-format)
strip-definerRemove DEFINER clauses from *.sql files
strip-partitioningRemove PARTITION BY clauses from *.sql files
update-viewsReformat views in canonical single-line form

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 definer users for lint-definer
allow-engineList of allowed storage engines for lint-engine
allow-pk-typeList of allowed data types for lint-pk-type
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 definer users listed in allow-definer for stored objects
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-fk-parentFlag foreign keys where same-schema parent table is missing or lacks unique key on referenced columns
lint-has-enumFlag columns using ENUM or SET data types
lint-has-eventFlag any use of events; intended for environments that restrict their presence
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-has-triggerFlag any use of triggers; intended for environments that restrict their presence
lint-has-viewFlag any use of views; intended for environments that restrict their presence
lint-name-caseFlag tables or views that have uppercase letters in their names
lint-pkFlag tables that lack a primary key
lint-pk-typeOnly allow primary keys to have types listed in allow-pk-type
lint-reserved-wordFlag names of tables, columns, routines, views, triggers, or events which match reserved words
lint-zero-dateFlag DATE, DATETIME, and TIMESTAMP columns that have zero-date default values

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-environmentOffload the temp schema to a different host, as configured by the specified environment
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 server
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-eventIgnore events that match regex
ignore-funcIgnore functions that match regex
ignore-procIgnore stored procedures that match regex
ignore-schemaIgnore schemas that match regex
ignore-tableIgnore tables or views that match regex
ignore-triggerIgnore triggers that match regex
ignore-viewIgnore views that match regex
my-cnfParse ~/.my.cnf for configuration (enabled by default; disable with skip-my-cnf)
passwordPassword for database user; omit value to prompt from TTY
server-public-key-pathFile path to server public key in PEM format; omit to obtain from server
sshTunnel MySQL connections thru SSH to this hostname or user@hostname:port
ssh-to-dbSSH to database host in order to establish database connections locally
ssl-caFile path to certificate authority in PEM format
ssl-certFile path to client-side public key in PEM format
ssl-keyFile path to client-side private key in PEM format
ssl-modeSpecify desired connection security SSL/TLS usage
ssl-verify-server-certVerify server-side cert matches server hostname
userUsername to connect to database host
versionDisplay program version