Registry / database / sequelize-migration-2

sequelize-migration-2

JSON →
library2.0.0jsnpmunverified

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.

npm install sequelize-migration-2
INSTALL
IMPORT
SIG · SEQUELIZE-MIGRATIO
S
sequelize-migration-2
databasejavascriptv2.0.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.

SequelizeMigration
const SequelizeMigration = require('sequelize-migration-2');
import SequelizeMigration from 'sequelize-migration-2';
Package does not ship ES modules; CommonJS only.
new SequelizeMigration(sequelize)
const migration = new SequelizeMigration(sequelize);
const migration = new SequelizeMigration(Sequelize);
Pass a Sequelize instance, not the Sequelize constructor.

Quickstart demonstrating installation, configuring Sequelize & SequelizeMigration, adding a migration module, and syncing.

// Install: npm install sequelize-migration-2 const Sequelize = require('sequelize'); const SequelizeMigration = require('sequelize-migration-2'); const sequelize = new Sequelize( process.env.DB_NAME ?? 'test', process.env.DB_USER ?? 'root', process.env.DB_PASS ?? '', { host: process.env.DB_HOST ?? 'localhost', dialect: 'mysql' } ); const migration = new SequelizeMigration(sequelize); migration.addModule({ name: 'my-module', dir: './scripts' }); migration.sync().then(() => { console.log('Migrations applied'); }); // Script directory structure: // scripts/ // mysql/ // 001_create_users.sql // postgres/ // 001_create_users.sql
Debug
Known issues
gotchaModule name must be unique across all added modules to avoid conflicts.
fix
Use a descriptive and unique name for each module, e.g., 'users' or 'orders'.
affects: >=0.0.0
gotchaScript directory structure must include a subfolder for each dialect (e.g., 'mysql', 'postgres'). Missing folders cause silent failures.
fix
Ensure your migration scripts are placed in dialect-specific subdirectories under the module directory.
affects: >=0.0.0
gotchaThe library creates a table named `db_migration` in your database; do not manually delete or alter it.
fix
Avoid direct modification of the `db_migration` table; use the library's sync method.
affects: >=0.0.0
breakingBreaking Change: In version 2.0.0, the constructor signature changed; it now expects a Sequelize instance directly, not an options object.
fix
Use `new SequelizeMigration(sequelize)` instead of `new SequelizeMigration({ sequelize })`.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'sequelize-migration-2'
Package not installed or not in node_modules.
fix
Run `npm install sequelize-migration-2` or `yarn add sequelize-migration-2`.
TypeError: SequelizeMigration is not a constructor
Incorrect import; likely using ESM import syntax.
fix
Use CommonJS require: `const SequelizeMigration = require('sequelize-migration-2');`
sequelize is not defined
Sequelize instance not properly created or passed to constructor.
fix
Create a Sequelize instance first: `const sequelize = new Sequelize(...);` then pass it to `new SequelizeMigration(sequelize);`
Cannot read properties of undefined (reading 'sync')
Migration module not added or incorrectly configured.
fix
Call `migration.addModule({ name: 'my-module', dir: 'path/to/scripts' });` before `migration.sync();`
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
sequelizerequiredPeer dependency; used to connect and execute migrations via Sequelize instance
Agent activity
11 hits · last 30 days
node
8
Meta
2
Resources
sequelize-migration-2 — npm install sequelize-migration-2 · libregistry