A wrapper for migrating databases using Sequelize and Umzug.
This module is tested with Node.js 14. It might work with Node.js >= 12, but is not tested.
npm install --save sequelize-migration-wrapper
import { setupMigration } from 'sequelize-migration-wrapper'; // TypeScript
const { setupMigration } = require('sequelize-migration-wrapper'); // CommonJS
const sequelize = new Sequelize({...});
setupMigration({
sequelize,
glob: 'path/to/migration/scripts/*.{js,ts}',
});- sequelize (no default, must be a Sequelize instance; required),
- glob (no default; required),
Runs through all migration scripts in the configured folder. Umzug automatically saves which migration scripts have already been run, so it will not re-run those.
await migrateDb.migrate();Get the current status of the migration
const status = await migrateDb.getStatus();Iteratively run through migration scripts.
for (const i in numberOfScriptsOrSomething) {
await migrateDb.migrateNext();
}Undo the last migration using Umzug's down function. This will only work if your migration scripts provide a down function. See Umzug's documentation for more details.
await migrateDb.reset();Iteratively undo a migration. This will only work if your migration scripts provide a down function. See Umzug's documentation for more details.
for (const i in numberOfScriptsOrSomething) {
await migrateDb.resetPrev();
}- Major update for
umzug - Breaking Change: a glob is now required instead of the
path/filePatterncombination - Security updates
- Security updates
- Complete rewrite in TypeScript
- Support for Sequelize 6
- Update dependencies to fix security vulnerabilities
- Initial release
This modules is maintained by Alex Seifert (Website, Github).