MigrationResult RunOutstandingMigrations() { if (Migrations.Any()) { Log("Running migrations" + (_isPreview ? " (preview mode)" : "")); } else { Log($"No migrations found in folder {_dir}"); } Log(); var result = new MigrationResult(); Migration current = null; try { foreach (var m in Migrations) { current = m; result.Attempted++; var mode = Migrate(m); switch (mode) { case MigrateMode.Skip: result.Skipped++; break; case MigrateMode.Run: result.Ran++; break; case MigrateMode.HashMismatch: result.Forced++; break; case MigrateMode.Rename: result.Renamed++; break; default: throw new ArgumentOutOfRangeException(message: "Unknown migration mode", null); } } if (_db.HasPendingTransaction) { _db.Commit(); } result.Success = true; } catch (Exception ex) { result.Success = false; result.Exception = ex; MigrationFailed(current, ex); } Log($"Attempted {result.Attempted} migrations."); if (result.Ran > 0) { Log(" Ran: " + result.Ran); } if (result.Forced > 0) { Log(" Forced: " + result.Forced); } if (result.Skipped > 0) { Log(" Skipped: " + result.Skipped); } if (result.Renamed > 0) { Log(" Renamed: " + result.Renamed); } Log(); Log((result.Success ? "SUCCESS" : "FAIL") + (_isPreview ? " (preview mode)" : "")); return(result); }