SQL Invariants
The sql step verifies database integrity directly.
Use it to assert:
- Database availability
- Schema invariants
- Migration state
- Critical data guarantees
Stoney currently supports Postgres.
Basic Example
version: 1
feature: demo
contracts:
- name: db_invariants
checks:
- id: db_smoke
work_item: "KAN-125"
says: "Database must be reachable and able to execute a simple query"
steps:
- sql:
driver: postgres
url_env: STONEY_DB_URL
query: "SELECT 1::int AS ok;"
expect:
rows: 1
equals:
ok: 1Safe-by-Default Behavior
Stoney protects your infrastructure:
- Write queries (INSERT, UPDATE, DELETE, DROP, etc.) are blocked
- Multi-statement SQL is blocked
- Queries are subject to timeout limits
To override (not recommended):
STONEY_ALLOW_WRITE_SQL=trueSTONEY_ALLOW_MULTI_SQL=true
Best Practices
- Use a least-privileged database user
- Prefer schema-level invariants over volatile data checks
- Avoid flaky data-dependent assertions
- Run against staging unless intentionally validating production
SQL contracts define infrastructure guarantees — not business workflows.
Last updated on