public override bool IsAltered(DbObject compare) { Column test = compare as Column; if (test != null) { if (!(test?.Expression ?? string.Empty).Equals(Expression ?? string.Empty)) { AlterDescription = $"Calculation expression changed from {test.Expression} to {Expression}"; return(true); } if (DataType.Equals("decimal") && string.IsNullOrEmpty(Expression)) { if (test.Scale != Scale) { AlterDescription = $"Scale changed from {test.Scale} to {Scale}"; return(true); } if (test.Precision != Precision) { AlterDescription = $"Precision changed from {test.Precision} to {Precision}"; return(true); } } if (!test.DataType.Equals(DataType)) { AlterDescription = $"Data type changed from {test.DataType} to {DataType}"; return(true); } if (DataType.StartsWith("var") || DataType.StartsWith("nvar")) { if (test.MaxLength != MaxLength) { AlterDescription = $"Max length changed from {test.MaxLength} to {MaxLength}"; return(true); } } if (test.IsNullable != IsNullable && string.IsNullOrEmpty(Expression)) { AlterDescription = $"Nullable changed from {test.IsNullable} to {IsNullable}"; return(true); } if (!(test?.Collation ?? string.Empty).Equals(Collation ?? test?.Collation ?? string.Empty)) { AlterDescription = $"Collation changed from {test.Collation} to {Collation}"; return(true); } // not sure how to handle defaults as they don't really impact the column def } return(false); }
private static void WriteCommands(SqlSyntax syntax, StreamWriter file, DbObject @object) { foreach (var cmd in @object.CreateCommands(syntax)) { WriteCommand(syntax, file, cmd); } EndBatch(syntax, file); }
public override bool IsAltered(DbObject compare) { var test = compare as Index; if (test != null) { if (!test.Columns.SequenceEqual(Columns)) { string newColumns = string.Join(", ", Columns.Select(col => $"{col.Name}-{col.SortDirection}")); string oldColumns = string.Join(", ", test.Columns.Select(col => $"{col.Name}-{col.SortDirection}")); AlterDescription = $"Index {Name} columns changed from {oldColumns} to {newColumns}"; return(true); } } return(false); }
public override bool IsAltered(DbObject compare) { ForeignKey test = compare as ForeignKey; if (test != null) { if (test.CascadeDelete != CascadeDelete) { AlterDescription = $"Cascade Update changed from {test.CascadeDelete} to {CascadeDelete}"; return(true); } if (test.CascadeUpdate != CascadeUpdate) { AlterDescription = $"Cascade Delete changed from {test.CascadeUpdate} to {CascadeUpdate}"; return(true); } } return(false); }
public override bool IsAltered(DbObject compare) { return(false); }
public override bool IsAltered(DbObject compare) { throw new System.NotImplementedException(); }
/// <summary> /// Returns true if an object was modified and needs to be altered or rebuilt /// </summary> public abstract bool IsAltered(DbObject compare);