/// <summary> /// Checks whether the current task will actually run any migrations. /// Can be used to decide whether it's necessary perform a backup before the migrations are executed. /// </summary> public bool HasMigrationsToApply() { using (var scope = new RunnerScope(this)) { switch (_runnerOptions.Task) { case null: case "": case "migrate": case "migrate:up": if (_runnerOptions.Version != 0) { return(scope.Runner.HasMigrationsToApplyUp(_runnerOptions.Version)); } return(scope.Runner.HasMigrationsToApplyUp()); case "rollback": case "rollback:all": // Number of steps doesn't matter as long as there's at least // one migration applied (at least that one will be rolled back) return(scope.Runner.HasMigrationsToApplyRollback()); case "rollback:toversion": case "migrate:down": return(scope.Runner.HasMigrationsToApplyDown(_runnerOptions.Version)); default: return(false); } } }
public async Task GetOwned_ScopeIsSet_AddsScopeParameter() { const string expected = "active"; const RunnerScope scope = RunnerScope.Active; await _sut.GetOwned(scope); _request.Received().AddParameterIfNotNull("scope", expected); }
public void Execute() { using (var scope = new RunnerScope(this)) { switch (_runnerOptions.Task) { case null: case "": case "migrate": case "migrate:up": if (_runnerOptions.Version != 0) { scope.Runner.MigrateUp(_runnerOptions.Version); } else { scope.Runner.MigrateUp(); } break; case "rollback": if (_runnerOptions.Steps == 0) { _runnerOptions.Steps = 1; } scope.Runner.Rollback(_runnerOptions.Steps); break; case "rollback:toversion": scope.Runner.RollbackToVersion(_runnerOptions.Version); break; case "rollback:all": scope.Runner.RollbackToVersion(0); break; case "migrate:down": scope.Runner.MigrateDown(_runnerOptions.Version); break; case "validateversionorder": scope.Runner.ValidateVersionOrder(); break; case "listmigrations": scope.Runner.ListMigrations(); break; } } _logger.LogSay("Task completed."); }