{"id":49317,"library":"sequelize-mtm-cli","title":"sequelize-mtm-cli","description":"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).","status":"active","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/itrootvm/sequelize-mtm-cli","tags":["javascript","sequelize","cli","migration","model","typescript"],"install":[{"cmd":"npm install sequelize-mtm-cli","lang":"bash","label":"npm"},{"cmd":"yarn add sequelize-mtm-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add sequelize-mtm-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required at runtime for the init script to create a Sequelize instance","package":"sequelize","optional":false},{"reason":"Needed to run the generated migrations","package":"sequelize-cli","optional":true}],"imports":[],"quickstart":{"code":"npm i sequelize-mtm-cli --save-dev\n\n# Create ./models/init.js:\nconst { Sequelize } = require('sequelize');\n\nmodule.exports = async () => {\n  const sequelize = new Sequelize({\n    dialect: 'sqlite',\n    storage: './db.sqlite',\n  });\n  await sequelize.authenticate();\n  return sequelize;\n};\n\n# In package.json add:\n\"scripts\": {\n  \"make:migrations\": \"sequelize-mtm-cli -s ./models/init.js -m ./db/migrations\",\n  \"run:migrations\": \"sequelize-cli db:migrate\"\n}\n\n# Generate migrations:\nnpm run make:migrations\n\n# Then run them:\nnpm run run:migrations","lang":"javascript","description":"Installs the CLI, creates a minimal Sequelize init script, sets up npm scripts to generate and run migrations, then executes them."},"warnings":[{"fix":"Compile TypeScript to JS first, e.g., using tsc, and point -s to the compiled output.","message":"The -s/--sequelize-path option currently only accepts JavaScript files. TypeScript files must be compiled to JS before use.","severity":"gotcha","affected_versions":"0.0.4"},{"fix":"Ensure module.exports = async () => { ... return sequelize; } is used.","message":"The init script must export a function that returns a Promise with a Sequelize instance; otherwise the CLI will fail.","severity":"gotcha","affected_versions":"0.0.4"},{"fix":"Commit generated migrations to version control and only regenerate when models change.","message":"Generated migrations use timestamp-based filenames; running the command multiple times may create duplicate or conflicting migration files.","severity":"gotcha","affected_versions":"0.0.4"},{"fix":"Stick with sequelize-cli unless the documentation updates.","message":"sequelize-cli db:migrate is assumed for running migrations; future versions may support alternative migration runners.","severity":"deprecated","affected_versions":"0.0.4"}],"env_vars":null,"search_vec":"'16.0.0':85 'accept':71 'addcolumn':33 'adopt':99 'alongsid':40 'async':53 'automat':15 'boilerpl':88 'cli':4,11,43,102 'communiti':98 'compar':21 'compil':79 'configur':57 'createt':31 'current':23,69 'custom':47 'definit':25 'design':82 'earli':95 'early-stag':94 'export':51 'file':19,73 'friend':65 'function':54 'generat':7,16 'helper':8 'init':48,76 'instanc':59 'javascript':72,100 'limit':97 'migrat':6,18,103 'model':24,104 'modifycolumn':34 'mtm':3 'node.js':84 'oper':37 'previous':28 'project':91 'reduc':87 'removecolumn':36 'removet':32 'requir':45,78 'return':55 'script':49,77 'sequel':2,5,17,42,58,90,101 'sequelize-c':41 'sequelize-mtm-c':1 'ship':66 'snapshot':29 'stage':96 'support':30 'tool':12,61 'type':67 'typescript':64,105 'typescript-friend':63 'use':81 'v0.0.4':13 'work':39","created_at":"2026-06-07T17:01:08.875334+00:00","updated_at":"2026-06-07T17:01:08.875334+00:00","problems":[{"fix":"Ensure the path is relative to the current working directory and the file exists. Use absolute paths if needed.","cause":"The init script path provided to -s does not exist or is incorrect.","error":"Error: Cannot find module './models/init.js' (or similar path)"},{"fix":"Verify that the exported function returns a Sequelize instance after calling authenticate().","cause":"The init script does not return a Sequelize instance correctly.","error":"TypeError: sequelize.authenticate is not a function"},{"fix":"Delete the previous migration folder contents before regenerating, or use a version control workflow.","cause":"Running the CLI multiple times generates new timestamps but may attempt to overwrite or duplicate migration files.","error":"Error: Migration file already exists: ..."},{"fix":"Use require/module.exports or set 'type': 'module' in package.json (but then sequelize-cli may also need ESM support).","cause":"The init script uses ES module syntax (import/export) but Node expects CommonJS.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/itrootvm/sequelize-mtm-cli#readme","github":"https://github.com/itrootvm/sequelize-mtm-cli","docs":null,"changelog":null,"pypi":null,"npm":"sequelize-mtm-cli","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}