MigrationSafe is a CLI tool (v0.1.8) that acts as a linter for PostgreSQL migration files, detecting dangerous operations like DROP TABLE, unsafe ALTER COLUMN, and missing indexes before they reach production. It provides severity levels (critical, warning, info), multiple output formats (terminal, JSON, Markdown, GitHub), and optional AI-powered rewrite suggestions via Claude. Unlike general SQL linting tools, it focuses specifically on migration safety and integrates with any migration framework. Released weekly on npm.
npm install migrationsafeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates installation and basic usage of the CLI tool to analyze a migration file.
Use a separate migration runner (e.g., Flyway, Liquibase) to apply changes.
Use -o <file> instead of --output <file>.
Set environment variable ANTHROPIC_API_KEY before using --fix.
Update CI scripts to check exit code 1 instead of non-zero.
Use double quotes: migrationsafe check "migrations/**/*.sql"
Wrap pattern in single or double quotes.
Use --format github for PR comments, or upgrade to v0.1.6+.
Use npx migrationsafe@latest check ... or install globally with npm install -g migrationsafe.
Verify the directory exists and adjust pattern: migrationsafe check 'migrations/**/*.sql'
Ensure the file has .sql extension and contains valid PostgreSQL syntax.
Wait before retrying or reduce call frequency.
Set the environment variable: export ANTHROPIC_API_KEY=your_key
No dependency data recorded yet.