mongo-migration

0.0.3 • Public • Published

Greenkeeper badge Build Status codecov

Simple, yet powerful mongo migration package

Features

  • tested right fromm the beginning
  • mongo-v3

Usage

Sample migration

const config = {
  url: "mongodb://localhost/",
  database: "migrationTest",
  migrationCollection: "migrations"
};
 
const testMigration = new Migration(testConfig);
testMigration.addFile(path.join(__dirname, "./migrations/a.js"));
testMigration.addFile(path.join(__dirname, "./migrations/b.js"));
const result = await testMigration.migrate();

Migration cleanup Removes non existent migrations from the migrations database and refreshes the hashes of already executed migrations. It doesn't actually run any migrations.

⚠️ This is a feature you shouldn't be required to use, but there might be rare cases where it get's useful.⚠️

const config = {
  url: "mongodb://localhost/",
  database: "migrationTest",
  migrationCollection: "migrations"
};
 
const testMigration = new Migration(testConfig);
testMigration.addFile(path.join(__dirname, "./migrations/a.js"));
testMigration.addFile(path.join(__dirname, "./migrations/b.js"));
const result = await testMigration.cleanup();

Readme

Keywords

Package Sidebar

Install

npm i mongo-migration

Weekly Downloads

44

Version

0.0.3

License

MIT

Unpacked Size

9.07 kB

Total Files

6

Last publish

Collaborators

  • sakulstra