Socket
Socket
Sign inDemoInstall

umzug

Package Overview
Dependencies
Maintainers
5
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

umzug

Framework-agnostic migration tool for Node


Version published
Weekly downloads
1M
increased by2.96%
Maintainers
5
Weekly downloads
Ā 
Created

What is umzug?

Umzug is a framework-agnostic migration tool for Node.js. It allows you to manage and execute database migrations, which are essential for evolving your database schema over time in a controlled and consistent manner.

What are umzug's main functionalities?

Running Migrations

This code demonstrates how to set up and run migrations using Umzug with Sequelize as the storage engine. The `up` method runs all pending migrations.

const { Sequelize } = require('sequelize');
const { Umzug, SequelizeStorage } = require('umzug');

const sequelize = new Sequelize('sqlite::memory:');

const umzug = new Umzug({
  migrations: { glob: 'migrations/*.js' },
  context: sequelize.getQueryInterface(),
  storage: new SequelizeStorage({ sequelize }),
  logger: console,
});

(async () => {
  await umzug.up();
})();

Reverting Migrations

This code demonstrates how to revert the last executed migration using the `down` method.

const { Sequelize } = require('sequelize');
const { Umzug, SequelizeStorage } = require('umzug');

const sequelize = new Sequelize('sqlite::memory:');

const umzug = new Umzug({
  migrations: { glob: 'migrations/*.js' },
  context: sequelize.getQueryInterface(),
  storage: new SequelizeStorage({ sequelize }),
  logger: console,
});

(async () => {
  await umzug.down();
})();

Listing Pending Migrations

This code demonstrates how to list all pending migrations using the `pending` method.

const { Sequelize } = require('sequelize');
const { Umzug, SequelizeStorage } = require('umzug');

const sequelize = new Sequelize('sqlite::memory:');

const umzug = new Umzug({
  migrations: { glob: 'migrations/*.js' },
  context: sequelize.getQueryInterface(),
  storage: new SequelizeStorage({ sequelize }),
  logger: console,
});

(async () => {
  const pendingMigrations = await umzug.pending();
  console.log(pendingMigrations);
})();

Other packages similar to umzug

Keywords

FAQs

Package last updated on 23 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc