Simple, yet powerful mongo migration package
- tested right fromm the beginning
- mongo-v3
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.
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();