Registry / devops / sequelize-mtm-cli

sequelize-mtm-cli

JSON →
library0.0.4jsnpmunverified

Sequelize Migration Generator Helper is a CLI tool (v0.0.4) that automatically generates Sequelize migration files by comparing your current model definitions against a previous snapshot, supporting createTable, removeTable, addColumn, modifyColumn, and removeColumn operations. It works alongside sequelize-cli and requires a custom init script that exports an async function returning a configured Sequelize instance. The tool is TypeScript-friendly (ships types) but currently only accepts JavaScript files for the init script, requiring compilation before use. Designed for Node.js >16.0.0, it reduces boilerplate for Sequelize projects but is early-stage (limited community adoption).

npm install sequelize-mtm-cli
INSTALL
IMPORT
SIG · SEQUELIZE-MTM-CLI
S
sequelize-mtm-cli
devopsjavascriptv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Installs the CLI, creates a minimal Sequelize init script, sets up npm scripts to generate and run migrations, then executes them.

npm i sequelize-mtm-cli --save-dev # Create ./models/init.js: const { Sequelize } = require('sequelize'); module.exports = async () => { const sequelize = new Sequelize({ dialect: 'sqlite', storage: './db.sqlite', }); await sequelize.authenticate(); return sequelize; }; # In package.json add: "scripts": { "make:migrations": "sequelize-mtm-cli -s ./models/init.js -m ./db/migrations", "run:migrations": "sequelize-cli db:migrate" } # Generate migrations: npm run make:migrations # Then run them: npm run run:migrations
Debug
Known issues
gotchaThe -s/--sequelize-path option currently only accepts JavaScript files. TypeScript files must be compiled to JS before use.
fix
Compile TypeScript to JS first, e.g., using tsc, and point -s to the compiled output.
affects: 0.0.4
gotchaThe init script must export a function that returns a Promise with a Sequelize instance; otherwise the CLI will fail.
fix
Ensure module.exports = async () => { ... return sequelize; } is used.
affects: 0.0.4
gotchaGenerated migrations use timestamp-based filenames; running the command multiple times may create duplicate or conflicting migration files.
fix
Commit generated migrations to version control and only regenerate when models change.
affects: 0.0.4
deprecatedsequelize-cli db:migrate is assumed for running migrations; future versions may support alternative migration runners.
fix
Stick with sequelize-cli unless the documentation updates.
affects: 0.0.4
Errors
Common errors & fixes
Error: Cannot find module './models/init.js' (or similar path)
The init script path provided to -s does not exist or is incorrect.
fix
Ensure the path is relative to the current working directory and the file exists. Use absolute paths if needed.
TypeError: sequelize.authenticate is not a function
The init script does not return a Sequelize instance correctly.
fix
Verify that the exported function returns a Sequelize instance after calling authenticate().
Error: Migration file already exists: ...
Running the CLI multiple times generates new timestamps but may attempt to overwrite or duplicate migration files.
fix
Delete the previous migration folder contents before regenerating, or use a version control workflow.
SyntaxError: Cannot use import statement outside a module
The init script uses ES module syntax (import/export) but Node expects CommonJS.
fix
Use require/module.exports or set 'type': 'module' in package.json (but then sequelize-cli may also need ESM support).
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
sequelizerequiredRequired at runtime for the init script to create a Sequelize instance
sequelize-clioptionalNeeded to run the generated migrations
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
sequelize-mtm-cli — npm install sequelize-mtm-cli · libregistry