Registry / database / migration-visualizer

migration-visualizer

JSON →
library0.4.0jsnpmunverified

A CLI tool that generates Mermaid ER diagrams from Knex.js and Kysely database migrations. Version 0.4.0 supports MySQL, PostgreSQL, and SQLite, with output in Mermaid format. It parses migration files to produce visual representations of table schemas, foreign keys, and indexes. Differentiator: no runtime database connection needed for Knex; for Kysely, connection details are required. Active development with CI and coverage reported.

npm install migration-visualizer
INSTALL
IMPORT
SIG · MIGRATION-VISUALIZ
M
migration-visualizer
databasejavascriptv0.4.0
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.

migration-visualizer
npx migration-visualizer visualize [options]
import or require() — not a programmatic API
This is a CLI tool only; there is no programmatic entry point.
CLI command
npx migration-visualizer visualize --orm knex --changed 20251227000006_create_likes.ts
migration-visualizer --orm knex --changed file.ts
The 'visualize' subcommand is mandatory.
Kysely usage
npx migration-visualizer visualize --orm kysely --dialect pg --host localhost --port 5432 --database mydb --user postgres --password secret --migrations ./migrations --changed 20251227000006_create_likes.ts
Missing --dialect or --migrations for Kysely
Kysely requires explicit dialect and migrations path; no config file is used.

Generate Mermaid ER diagram from a single knex migration file.

npx migration-visualizer visualize --orm knex --changed 20251227000006_create_likes.ts
Debug
Known issues
gotchaKysely requires database connection credentials and dialect; unlike Knex, no config file is detected automatically.
fix
Provide --dialect, --migrations, and optionally --host, --port, --database, --user, --password (or --filename for SQLite).
affects: *
gotchaThe tool expects migration files to follow Knex/Kysely naming conventions; custom patterns may not be parsed.
fix
Ensure migration filenames match the timestamp format (e.g., 20251227000006_create_likes.ts).
affects: *
gotchaOutput is currently only Mermaid; no other formats (e.g., SVG, PNG) are supported.
fix
Use external Mermaid renderers (e.g., mermaid-cli) to convert to other formats.
affects: <1.0.0
Errors
Common errors & fixes
Error: Unknown option '--orm'
The 'visualize' subcommand was omitted; arguments were passed directly to the root command.
fix
Run: npx migration-visualizer visualize --orm knex ...
Error: Missing required argument: --dialect
Used Kysely without specifying the database dialect.
fix
Add --dialect mysql2 or --dialect pg or --dialect sqlite3 to the command.
Error: Not a valid migration file: 20251227_test.sql
The file extension is not .ts or .js; Knex/Kysely migrations are typically JavaScript/TypeScript files.
fix
Use .ts or .js files for migration files, or rename the file accordingly.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
migration-visualizer — npm install migration-visualizer · libregistry