@neo9/n9-mongodb-migration

Project to run migration script on mongodb.

Usage no npm install needed!

<script type="module">
  import neo9N9MongodbMigration from 'https://cdn.skypack.dev/@neo9/n9-mongodb-migration';
</script>

README

n9-mongodb-migration

Project to run migration script on mongodb.

npm version Travis Coverage

simple usage :

import { N9MongodbMigration } from '@neo9/n9-mongodb-migration';

const mongodbPatchApplier = new N9MongodbMigration({
    migrationScriptsFolderPath: './scripts',
    mongodbURI: process.env.MONGODB_URI,
});

await mongodbPatchApplier.apply();

Scripts names :

x.y.z_dscription-of-the-upgrade.js

Script example :

async function up(db, log) {
    await db.collection('test').insertOne({
        test: true,
    });
}

async function down(db, log) {
    await db.collection('test').deleteOne({
        test: true,
    });
}

module.exports = { up, down };

More examples can be found in the tests folder.