db-migrate vs migrate
Choose a database migration framework or a general change runner
db-migratemigrateSimilar Packages:

Choose a database migration framework or a general change runner

db-migrate supplies database-oriented migration tooling and separate drivers, while migrate runs ordered application-defined up/down functions with configurable state storage. The right choice depends on who supplies the database operations and execution history.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
db-migrate209,1772,337271 kB467 days agoMIT
migrate97,8951,53943.3 kB233 years agoMIT

Decide how much database behavior the tool should provide

db-migrate is oriented toward database changes. Its CLI works with database-specific drivers, including the documented MySQL, PostgreSQL, SQLite and MongoDB routes. Installing the migration framework is not equivalent to installing every driver or making every database operation portable. Check the selected driver and its supported operations before sharing migrations across databases.

migrate is a general change runner. Migration files expose up and down functions containing the application's actual work. That can include database calls, but the runner does not automatically supply a relational schema builder or infer equivalent database operations.

Plan execution history

migrate's default state is stored in a .migrate file. It can use a custom state store with load and save methods when execution history belongs elsewhere. The programmatic API loads a migration set and runs up or down. Migration functions can complete through callbacks or the documented async-function path; the runner must observe the work's actual completion.

With db-migrate, configure the database and appropriate driver according to the framework's integration instructions. A driver-backed workflow and an application-defined state file have different deployment and operational requirements.

Keep runtime and rollback expectations explicit

The current db-migrate README officially supports Node 24 and newer, with older runtimes untested. The current migrate manifest declares Node 14 or later. A generic claim that both work on any Node installation would hide a useful adoption condition.

Neither a down function nor applied-state tracking proves that arbitrary business changes can be reversed or that the whole operation is transactional. Implement and test the intended database operations and rollback behavior in the application's deployment process. Prefer db-migrate for its driver-based workflow, or migrate when a smaller general runner and application-owned operations are the better fit.

How to Choose: db-migrate vs migrate

  • db-migrate:

    Choose the database-oriented CLI and driver ecosystem when they match the required database and deployment environment.

  • migrate:

    Choose a general ordered up/down workflow when the application should provide the actual operations and its own state-store integration if needed.

README for db-migrate

Backers on Open Collective Sponsors on Open Collective Build Status Documentation Status

db-migrate

Join the chat at https://gitter.im/db-migrate/node-db-migrate

NPM

Database migration framework for node.js

New: db-migrate for meta

db-migrate rewritten in meta: your program ships with its migrations compiled in, as one binary, no node.js needed to migrate. It uses the same migrations table and the same state as db-migrate, v2 migrations included, so a database migrated by one of them can be carried on by the other.

Try meta-db-migrate

Platinum sponsors

Details about sponsorships

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor] or reach out to [email protected].

Usage

Upgrading from 0.11

db-migrate 0.11 and older are end of life. See the changelog of 1.0.0 for what changed, v1 migrations keep working unchanged.

Requirements

Officially supported is Node.js 24 and newer. Older versions may work, but are not tested.

Installation

$ npm install -g db-migrate

DB-Migrate is now available to you via:

$ db-migrate

As local module

Want to use db-migrate as local module?

$ npm install db-migrate

DB-Migrate is now available to you via:

$ node node_modules/db-migrate/bin/db-migrate

Officially Supported Databases

Connecting through an SSH tunnel

Tunnels are provided by plugins. Install the ssh tunnel plugin next to db-migrate to use the tunnel setting of your database config:

$ npm install db-migrate-plugin-tunnel-ssh

Resources and usage instructions

Please follow the link below, for usage instructions examples and the full documentation of db-migrate.

Documentation: https://db-migrate.readthedocs.io/en/latest/

Support db-migrate

Backers

A big thank you to our backers. You're a tremendous and important help, to keep the project healthy! [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor] or reach out to [email protected].

License

(The MIT License)

Copyright (c) 2015 Tobias Gurtzick

Copyright (c) 2013 Jeff Kunkle

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.