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
Option | Description |
---|---|
format | Reformat SQL statements to match canonical SHOW CREATE (enabled by default; disable with skip-format) |
strip-definer | Remove DEFINER clauses from *.sql files |
strip-partitioning | Remove PARTITION BY clauses from *.sql files |
update-views | Reformat views in canonical single-line form |
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 definer users for lint-definer |
allow-engine | List of allowed storage engines for lint-engine |
allow-pk-type | List of allowed data types for lint-pk-type |
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 definer users listed in allow-definer for stored objects |
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-fk-parent | Flag foreign keys where same-schema parent table is missing or lacks unique key on referenced columns |
lint-has-enum | Flag columns using ENUM or SET data types |
lint-has-event | Flag any use of events; intended for environments that restrict their presence |
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-has-trigger | Flag any use of triggers; intended for environments that restrict their presence |
lint-has-view | Flag any use of views; intended for environments that restrict their presence |
lint-name-case | Flag tables or views that have uppercase letters in their names |
lint-pk | Flag tables that lack a primary key |
lint-pk-type | Only allow primary keys to have types listed in allow-pk-type |
lint-reserved-word | Flag names of tables, columns, routines, views, triggers, or events which match reserved words |
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-environment | Offload the temp schema to a different host, as configured by the specified environment |
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 server |
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-event | Ignore events that match regex |
ignore-func | Ignore functions that match regex |
ignore-proc | Ignore stored procedures that match regex |
ignore-schema | Ignore schemas that match regex |
ignore-table | Ignore tables or views that match regex |
ignore-trigger | Ignore triggers that match regex |
ignore-view | Ignore views that match regex |
my-cnf | Parse ~/.my.cnf for configuration (enabled by default; disable with skip-my-cnf) |
password | Password for database user; omit value to prompt from TTY |
server-public-key-path | File path to server public key in PEM format; omit to obtain from server |
ssh | Tunnel MySQL connections thru SSH to this hostname or user@hostname:port |
ssh-to-db | SSH to database host in order to establish database connections locally |
ssl-ca | File path to certificate authority in PEM format |
ssl-cert | File path to client-side public key in PEM format |
ssl-key | File path to client-side private key in PEM format |
ssl-mode | Specify desired connection security SSL/TLS usage |
ssl-verify-server-cert | Verify server-side cert matches server hostname |
user | Username to connect to database host |
version | Display program version |