Skip to content

Lint rules

The linter analyzes migration plans before execution and warns about dangerous patterns.

Terminal window
npx @smplcty/schema-flow lint --db postgresql://user:pass@localhost:5432/mydb
RuleSeverityDescription
set-not-null-directWarningDirect SET NOT NULL without the safe CHECK pattern. Can lock the table for a full scan.
add-column-with-defaultWarningAdding a column with a volatile default. May lock the table on older PostgreSQL versions.
drop-columnWarningDropping a column causes data loss.
drop-tableWarningDropping a table causes data loss.
type-narrowingWarningNarrowing a column type (e.g., text -> varchar(50)) can fail if existing data doesn’t fit.
type-changeWarningChanging column type may require a full table rewrite.
missing-fk-indexInfoForeign key column without an index. Causes slow joins and slow cascading deletes.
rename-detectionInfoDetected a possible rename (drop + add with same type). Consider using expand/contract instead.
import { lintPlan } from '@smplcty/schema-flow';
const result = lintPlan(plan);
for (const warning of result.warnings) {
console.log(`[${warning.severity}] ${warning.rule}: ${warning.message}`);
// warning.operation — the operation that triggered the warning
}