A .Net Standard library to help manage Mongo migrations. Similar to migrate-mongo but with .Net
Install BoomTown.MongoMigrate
Create an IMigration
private class SampleMigration : IMigration
{
public DateTime ChangeDate() { /*Todays Date */ }
public Task Up(IMongoDatabase database) { /* Your Migration */ }
public Task Down(IMongoDatabase database) { /* How to undo your migration */ }
}
Run Up()
var database = new MongoClient(connectionString).GetDatabase("users");
var runner = new MongoMigrationsRunner<SampleMigration>(database);
// Run the migrations
await runner.Up();
Check the Status of the migrations
await _runner.GetAppliedMigrations();
If you need to undo your last migration
await _runner.Down();
If you need to undo all your migrations
await _runner.DownAll();