{"id":49314,"library":"sequelize-migration-2","title":"Sequelize Migration 2","description":"Sequelize Migration 2 is a Node.js library for managing database migrations using raw SQL scripts in Sequelize projects. Version 2.0.0 focuses on MySQL and PostgreSQL, with untested support for other dialects. It creates a `db_migration` table to track applied migrations and supports modular script directories per dialect. Compared to other tools, it relies purely on SQL files rather than JavaScript-based migrations, and the release cadence is low, with no major updates since 2020. Key differentiators include simplicity, dialect-specific folders, and optional MD5 checksum verification planned for future releases.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sergiofilhowz/sequelize-migration-2","tags":["javascript","sequelize","migration"],"install":[{"cmd":"npm install sequelize-migration-2","lang":"bash","label":"npm"},{"cmd":"yarn add sequelize-migration-2","lang":"bash","label":"yarn"},{"cmd":"pnpm add sequelize-migration-2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; used to connect and execute migrations via Sequelize instance","package":"sequelize","optional":false}],"imports":[{"note":"Package does not ship ES modules; CommonJS only.","wrong":"import SequelizeMigration from 'sequelize-migration-2';","symbol":"SequelizeMigration","correct":"const SequelizeMigration = require('sequelize-migration-2');"},{"note":"Pass a Sequelize instance, not the Sequelize constructor.","wrong":"const migration = new SequelizeMigration(Sequelize);","symbol":"new SequelizeMigration(sequelize)","correct":"const migration = new SequelizeMigration(sequelize);"}],"quickstart":{"code":"// Install: npm install sequelize-migration-2\nconst Sequelize = require('sequelize');\nconst SequelizeMigration = require('sequelize-migration-2');\n\nconst sequelize = new Sequelize(\n  process.env.DB_NAME ?? 'test',\n  process.env.DB_USER ?? 'root',\n  process.env.DB_PASS ?? '',\n  {\n    host: process.env.DB_HOST ?? 'localhost',\n    dialect: 'mysql'\n  }\n);\n\nconst migration = new SequelizeMigration(sequelize);\nmigration.addModule({\n  name: 'my-module',\n  dir: './scripts'\n});\n\nmigration.sync().then(() => {\n  console.log('Migrations applied');\n});\n\n// Script directory structure:\n// scripts/\n//   mysql/\n//     001_create_users.sql\n//   postgres/\n//     001_create_users.sql","lang":"javascript","description":"Quickstart demonstrating installation, configuring Sequelize & SequelizeMigration, adding a migration module, and syncing."},"warnings":[{"fix":"Use a descriptive and unique name for each module, e.g., 'users' or 'orders'.","message":"Module name must be unique across all added modules to avoid conflicts.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure your migration scripts are placed in dialect-specific subdirectories under the module directory.","message":"Script directory structure must include a subfolder for each dialect (e.g., 'mysql', 'postgres'). Missing folders cause silent failures.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid direct modification of the `db_migration` table; use the library's sync method.","message":"The library creates a table named `db_migration` in your database; do not manually delete or alter it.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `new SequelizeMigration(sequelize)` instead of `new SequelizeMigration({ sequelize })`.","message":"Breaking Change: In version 2.0.0, the constructor signature changed; it now expects a Sequelize instance directly, not an options object.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2':3,6 '2.0.0':23 '2020':79 'appli':43 'base':66 'cadenc':71 'checksum':91 'compar':52 'creat':36 'databas':13 'db':38 'dialect':34,51,85 'dialect-specif':84 'differenti':81 'directori':49 'file':61 'focus':24 'folder':87 'futur':95 'includ':82 'javascript':65,97 'javascript-bas':64 'key':80 'librari':10 'low':73 'major':76 'manag':12 'md5':90 'migrat':2,5,14,39,44,67,99 'modular':47 'mysql':26 'node.js':9 'option':89 'per':50 'plan':93 'postgresql':28 'project':21 'pure':58 'rather':62 'raw':16 'releas':70,96 'reli':57 'script':18,48 'sequel':1,4,20,98 'simplic':83 'sinc':78 'specif':86 'sql':17,60 'support':31,46 'tabl':40 'tool':55 'track':42 'untest':30 'updat':77 'use':15 'verif':92 'version':22","created_at":"2026-06-07T17:01:08.195463+00:00","updated_at":"2026-06-07T17:01:08.195463+00:00","problems":[{"fix":"Run `npm install sequelize-migration-2` or `yarn add sequelize-migration-2`.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'sequelize-migration-2'"},{"fix":"Use CommonJS require: `const SequelizeMigration = require('sequelize-migration-2');`","cause":"Incorrect import; likely using ESM import syntax.","error":"TypeError: SequelizeMigration is not a constructor"},{"fix":"Create a Sequelize instance first: `const sequelize = new Sequelize(...);` then pass it to `new SequelizeMigration(sequelize);`","cause":"Sequelize instance not properly created or passed to constructor.","error":"sequelize is not defined"},{"fix":"Call `migration.addModule({ name: 'my-module', dir: 'path/to/scripts' });` before `migration.sync();`","cause":"Migration module not added or incorrectly configured.","error":"Cannot read properties of undefined (reading 'sync')"}],"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/sergiofilhowz/sequelize-migration-2#readme","github":"https://github.com/sergiofilhowz/sequelize-migration-2","docs":null,"changelog":null,"pypi":null,"npm":"sequelize-migration-2","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}