private void RunMigrations(MigratorBase migrator) { // We only support UP right now. // Find the target migration and collect everything between the start and it var toApply = new List <string>(); // TakeWhile won't work because it doesn't include the actual target :( foreach (var migration in migrator.GetPendingMigrations()) { toApply.Add(migration); if (IsMigration(migration, TargetMigration)) { break; } } if (!toApply.Any(s => IsMigration(s, TargetMigration))) { Log.Error("{0} is not a pending migration. Only the UP direction can be run in this way. Use the -Sql option to script downwards migrations.", TargetMigration); return; } // We have a list of migrations to apply, apply them one-by-one foreach (var migration in toApply) { Log.Info("Applying {0}", migration); if (!WhatIf) { migrator.Update(migration); } } Log.Info("All requested migrations applied"); }
protected override void ExecuteCommandCore(MigratorBase migrator) { Log.Info("Migration Status for {0} on {1}", ConnectionString.InitialCatalog, ConnectionString.DataSource); foreach (var migration in migrator.GetDatabaseMigrations().Reverse()) { Log.Info("A {0}", migration); } foreach (var migration in migrator.GetPendingMigrations()) { Log.Info(" {0}", migration); } Log.Info("A = Applied"); }