ez-migrate

0.0.26 • Public • Published

EZ Migrate

THIS PACKAGE IS STILL IN DEVELOPMENT SO USE AT YOUR OWN RISK!

This is a database-agnostic data migration orchestration CLI tool.

Installation

$ npm install -g ez-migrate

Cli interface

  Usage: ez-migrate [options]

  Options:

    init                 Initializes migrations folder
    run [migration]      Runs migration [migration]
    revert [migration]   Reverts migration [migration]
    revert-all           Reverts all executed migrations
    run-latest           Executes migrations that have not been run
    executed-migrations  List of executed migrations

SAMPLE MIGRATION FILE:

const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:27017/test';

module.exports = {
    async up() {
        const client = await MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true });
        if (!client) return;

        const db = client.db('test');
        await db.collection('cars').insertOne({
            make: "audi",
            model: "R8"
        });
    },

    async down() {
        const client = await MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true });
        if (!client) return;

        const db = client.db('test');
        await db.collection('cars').remove();
    }
}

Readme

Keywords

Package Sidebar

Install

npm i ez-migrate

Weekly Downloads

1

Version

0.0.26

License

MIT

Unpacked Size

7.52 kB

Total Files

7

Last publish

Collaborators

  • jtn1490