Skip to content

BoomTownROI/BoomTown.MongoMigrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoomTown.MongoMigrate

A .Net Standard library to help manage Mongo migrations. Similar to migrate-mongo but with .Net

Getting Started

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();