private void ExecuteList() { Console.WriteLine("==============================="); Console.WriteLine("Humpback Migration List"); var migrations = _migration_provider.GetMigrations(); Console.WriteLine( // Couldn't help myself, leaving in the 'SSt' is enough for © stuff http://www.ascii-art.net/about.php @" __________...----..____..-'``-..___ ,'. ```--.._ : ``._ | -- ``. | <o> -.- -. - -. `. : __ -- . \ `._____________ ( `. -.- -- - . ` \ `-----------------\ \_.--------..__..--.._ `. `. : `--' SSt `-._ . | `.` | \` | \ | / \`. / _\-' /_,' "); // yes i know thats not actually a humpback whale, its a sperm whale, but for now thats too bad, theres not a lot of ascii whale photos to choose from. // also, if user doesnt' have monospaced font in their shell, it wont render right. bummer for them! Console.WriteLine(migrations.Count + @" Migrations \o/ means it is currently deployed ================================================================="); int db_version = _migration_provider.DatabaseMigrationNumber(); foreach (var m in migrations) { Console.WriteLine("{0} {1} {2}", (m.Key > db_version ? " " : "\\o/"), ((m.Key).ToString()).PadLeft(3), new FileInfo(m.Value).Name); } }
private void SaveUnDeployed() { var migrations = _migration_provider.GetMigrations(); var migration_contents = _migration_provider.GetMigrationsContents(); CreateSql(migrations, migration_contents, v => v.Key > _migration_provider.DatabaseMigrationNumber()); }
// > hump -m -all | updates database to most recent migration // > hump -m 12 | updates database to a specific migration (up or down) // > hump -m -up | migrates database up one migration // > hump -m -down | migrates database down one migration // > hump -m -empty | removes all migrations from database // > hump -m -reset | removes and re-adds all migrations (-empty, then -all) public void Execute() { int top_migration = _migration_provider.GetMigrations().Max(m => m.Key); int current_migration = _migration_provider.DatabaseMigrationNumber(); if (current_migration > top_migration) { current_migration = top_migration; } if (_configuration.All) { MigrateTo(top_migration); } else if (_configuration.Up) { MigrateTo(++current_migration); } else if (_configuration.Down) { MigrateTo(--current_migration); } else if (_configuration.Empty) { MigrateTo(0); } else if (_configuration.Reset) { MigrateTo(0); MigrateTo(top_migration); } else if (SingleMigrationID() > 0) { MigrateTo(SingleMigrationID()); } else { MigrateTo(top_migration); } }