Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mikro-orm/migrations

Package Overview
Dependencies
Maintainers
1
Versions
3206
Alerts
File Explorer

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.

  • 6.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
138K
decreased by-8.92%
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

Keywords

FAQs

Package last updated on 11 Nov 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