Registry / database / migrationsafe

migrationsafe

JSON →
library0.1.8jsnpmunverified

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 migrationsafe
INSTALL
IMPORT
SIG · MIGRATIONSAFE
M
migrationsafe
databasejavascriptv0.1.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI
npx migrationsafe@latest check 'migrations/**/*.sql'
npm run migrationsafe check
No package-level imports; use CLI directly via npx or global install.
default
import migrationsafe from 'migrationsafe'
const migrationsafe = require('migrationsafe')
Not a Node.js library; it's a CLI tool. No JS import available.
runner
node ./node_modules/.bin/migrationsafe check ...
node migrationsafe check ...
If installed locally, use the bin path.

Demonstrates installation and basic usage of the CLI tool to analyze a migration file.

# Install globally npm install -g migrationsafe # Create a test migration file echo 'CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);' > migration.sql # Check the migration migrationsafe check migration.sql --verbose # Output as JSON for CI migrationsafe check migration.sql --format json
Debug
Known issues
gotchaTool does not run migrations; it only scans files for dangerous patterns.
fix
Use a separate migration runner (e.g., Flyway, Liquibase) to apply changes.
affects: >=0.0.1
deprecatedOption --output file is replaced by -o <file> in v0.1.5+.
fix
Use -o <file> instead of --output <file>.
affects: <0.1.5
gotchaAI rewrites require ANTHROPIC_API_KEY; cost may apply.
fix
Set environment variable ANTHROPIC_API_KEY before using --fix.
affects: >=0.1.0
breakingVersion 0.1.0 changed exit codes: now 1 for failures, 0 for success.
fix
Update CI scripts to check exit code 1 instead of non-zero.
affects: <0.1.0
gotchaGlob patterns on Windows may require quotes or escape characters.
fix
Use double quotes: migrationsafe check "migrations/**/*.sql"
affects: >=0.0.1
gotchaFile pattern must be quoted in some shells to prevent glob expansion.
fix
Wrap pattern in single or double quotes.
affects: >=0.0.1
deprecated--format markdown output may have inconsistent heading levels across versions.
fix
Use --format github for PR comments, or upgrade to v0.1.6+.
affects: <0.1.6
Errors
Common errors & fixes
Command not found: migrationsafe
Package not installed globally or npx not available.
fix
Use npx migrationsafe@latest check ... or install globally with npm install -g migrationsafe.
Pattern 'migrations/*.sql' matched 0 files
Glob pattern does not match any files or path is incorrect.
fix
Verify the directory exists and adjust pattern: migrationsafe check 'migrations/**/*.sql'
Error: Failed to parse SQL file
File is not a valid SQL file or contains unsupported syntax.
fix
Ensure the file has .sql extension and contains valid PostgreSQL syntax.
Request failed with 429 Too Many Requests
AI rewrite API rate limited.
fix
Wait before retrying or reduce call frequency.
ANTHROPIC_API_KEY environment variable is not set
--fix option used without API key.
fix
Set the environment variable: export ANTHROPIC_API_KEY=your_key
Upgrade
Version history
0.1.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources