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 statements to their canonical form, just like skeema format
.
This command relies on accessing database instances 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 CLI 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.
Lint Options
Option | Description |
---|---|
format | Reformat SQL statements to match canonical SHOW CREATE (enabled by default) |
Linter Rule Options
Option | Description |
---|---|
allow-auto-inc | List of allowed auto_increment column data types for lint-auto-inc |
allow-charset | List of allowed character sets for lint-charset |
allow-compression | List of allowed compression settings for lint-compression |
allow-definer | List of allowed routine definers for lint-definer |
allow-engine | List of allowed storage engines for lint-engine |
lint-auto-inc | Only allow auto_increment column data types listed in allow-auto-inc |
lint-charset | Only allow character sets listed in allow-charset |
lint-compression | Only allow compression settings listed in allow-compression |
lint-definer | Only allow routine definers listed in allow-definer |
lint-display-width | Only allow default display width for int types |
lint-dupe-index | Flag redundant secondary indexes |
lint-engine | Only allow storage engines listed in allow-engine |
lint-has-fk | Flag any use of foreign keys; intended for environments that restrict their presence |
lint-has-float | Flag columns using FLOAT or DOUBLE data types |
lint-has-routine | Flag any use of stored procs or funcs; intended for environments that restrict their presence |
lint-has-time | Flag columns using TIMESTAMP, DATETIME, or TIME data types |
lint-pk | Flag tables that lack a primary key |
lint-zero-date | Flag DATE, DATETIME, and TIMESTAMP columns that have zero-date default values |
Workspace Options
Option | Description |
---|---|
docker-cleanup | With workspace=docker, specifies how to clean up containers |
temp-schema | Name of temporary schema for intermediate operations, created and dropped each run |
temp-schema-binlog | Controls whether temp schema DDL operations are replicated |
temp-schema-threads | Max number of concurrent CREATE/DROP with workspace=temp-schema |
workspace | Specifies where to run intermediate operations |
Global Options
Option | Description |
---|---|
connect-options | Comma-separated session options to set upon connecting to each database instance |
debug | Enable debug logging |
help | Display usage information for the specified command |
host-wrapper | External bin to shell out to for host lookup; see manual for template vars |
ignore-schema | Ignore schemas that match regex |
ignore-table | Ignore tables that match regex |
my-cnf | Parse ~/.my.cnf for configuration (enabled by default) |
password | Password for database user; omit value to prompt from TTY (default no password) |
user | Username to connect to database host |
version | Display program version |