New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@mikro-orm/migrations

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/migrations

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.


Version published
Weekly downloads
165K
increased by1.38%
Maintainers
1
Weekly downloads
 
Created

What is @mikro-orm/migrations?

@mikro-orm/migrations is a package for handling database migrations in MikroORM, an ORM for Node.js. It allows you to create, run, and manage database schema changes in a structured and version-controlled manner.

What are @mikro-orm/migrations's main functionalities?

Creating Migrations

This feature allows you to create a new migration file based on the current state of your entities. The migration file will contain the necessary SQL statements to update the database schema.

const { MikroORM } = require('@mikro-orm/core');
const { Migrator } = require('@mikro-orm/migrations');

(async () => {
  const orm = await MikroORM.init();
  const migrator = orm.getMigrator();
  await migrator.createMigration(); // creates file MigrationYYYYMMDDHHMMSS.ts
})();

Running Migrations

This feature allows you to apply all pending migrations to the database, ensuring that the schema is up-to-date with the latest changes.

const { MikroORM } = require('@mikro-orm/core');
const { Migrator } = require('@mikro-orm/migrations');

(async () => {
  const orm = await MikroORM.init();
  const migrator = orm.getMigrator();
  await migrator.up(); // runs all pending migrations
})();

Reverting Migrations

This feature allows you to revert the last applied migration, which is useful for rolling back changes in case of errors or issues.

const { MikroORM } = require('@mikro-orm/core');
const { Migrator } = require('@mikro-orm/migrations');

(async () => {
  const orm = await MikroORM.init();
  const migrator = orm.getMigrator();
  await migrator.down(); // reverts the last migration
})();

Other packages similar to @mikro-orm/migrations

FAQs

Package last updated on 20 Jul 2020

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