v0.1.0

Validate and lint

Check that the model is sound, check it against PostgreSQL best practices, and apply safe fixes.

Two commands check a project, and both work offline.

databee validate
databee lint

Validate

validate checks the project files and the structure of the model: the file format, references between objects, types. Findings carry a code such as DB-VAL-… and the file and JSON path of the value at fault. --fix applies every machine-applicable fix and then validates again.

Lint

lint applies rules that go beyond what is invalid. The PostgreSQL rules are:

Rule Finds
PG001 Table has no primary key
PG002 Foreign key has no index whose leading fields cover the key fields
PG003 Index fields are a prefix of another index with the same predicate
PG005 Text length limit without a business reason
PG006 Timestamp without time zone
PG014 Table with more than 10 fields has no comment
PG016 Default calls nextval of a sequence the model does not know
PG017 Identifier longer than 63 bytes, or equal to another after PostgreSQL truncates it

Rules are scoped by dialect: PG001, PG003 and PG014 apply to every relational dialect, PG002 to PostgreSQL and SQLite, and PG005, PG006, PG016 and PG017 to PostgreSQL only. Collections of a MongoDB project are not checked by relational rules.

Configure

Severities, the failure threshold and suppressions live in project.toml:

[lint]
fail_on = "warning"

[lint.severity]
PG006 = "error"
PG014 = "off"

fail_on is the lowest severity that makes validate and lint exit with 1 (error by default). A suppression switches one rule off for one model object by ID and must give a reason; one without a reason is reported as DB-LINT-001, one pointing at a missing object as DB-LINT-002.

Output for CI

--format json (or --json) prints one JSON object, and --format sarif produces SARIF for code scanning. --fail-on error|warning|info overrides the configured threshold for one run.

Fixes

--fix applies the corrections a finding marks as available, such as adding the index PG002 asks for. A fix is recorded as an undo step, so databee undo takes it back.

Edit this page on GitHub · Docs for v0.1.0