private static DeploymentStepDecision RemoveDataLossCheckStep(DeploymentStep step, KeeperDecider decider) { var dlcStep = new DataLossCheckStep(step); return(!dlcStep.IsDataLossCheck ? null : new DeploymentStepDecision() { Remove = decider.ShouldRemoveFromPlan(dlcStep.ObjectName, ModelSchema.Table, StepType.Drop), StepType = StepType.DataLossCheck, ObjectName = dlcStep.ObjectName.ToString() }); }
private static string[] GetAllIdentifiersFromStep(DeploymentStep sourceStep) { var tokens = new List <string>(); if (sourceStep is CreateElementStep) { var step = sourceStep as CreateElementStep; var statement = step.Script .AsOptional(s => s as TSqlScript) .ValueOrDefault(s => s?.Batches) .OptionalAt(0).ValueOrDefault(b => b?.Statements) .OptionalAt(0); var column = GetColumnFromAlterTableStatement(statement.Evaluate()); var tableTokens = GetTableTokensFromAlterTableStatement(statement.Evaluate()); tokens.Add(step.SourceElement?.Name?.ToString() ?? ""); tokens.Add(column.Evaluate()); tokens.Add(tableTokens.Evaluate()); } else if (sourceStep is DropElementStep) { var step = sourceStep as DropElementStep; //todo optional stuff tokens.Add(step.TargetElement?.Name?.ToString() ?? ""); } else if (sourceStep is AlterElementStep) { var step = sourceStep as AlterElementStep; //todo optional stuff tokens.Add(step.TargetElement?.Name?.ToString() ?? ""); } else { var step = new DataLossCheckStep(sourceStep); if (step != null && step.IsDataLossCheck) { //todo optional stuff tokens.Add(step.ObjectName.ToString()); } } return(tokens.ToArray()); }
private static DeploymentStepDecision RemoveDataLossCheckStep(DeploymentStep step, KeeperDecider decider) { var dlcStep = new DataLossCheckStep(step); if (dlcStep == null || !dlcStep.IsDataLossCheck) { return(null); } var objectNames = GetAllIdentifiersFromStep(step); return(new DeploymentStepDecision() { Remove = decider.ShouldRemoveFromPlan(new ObjectIdentifier(objectNames), ModelSchema.Table, StepType.Drop), StepType = StepType.DataLossCheck, ObjectNames = objectNames }); }