private static void CheckPrimaryKey(Column old, Column @new, ColumnMetaChange metaChange) { if (old.IsPrimaryKey && [email protected]) { metaChange.Set(ColumnChanges.NonPrimary); } else if (!old.IsPrimaryKey && @new.IsPrimaryKey) { metaChange.Set(ColumnChanges.PrimaryKey); } }
private static void CheckUnique(Column old, Column @new, ColumnMetaChange metaChange) { if (old.IsUnique && [email protected]) { metaChange.Set(ColumnChanges.NonUnique); } else if (!old.IsUnique && @new.IsUnique) { metaChange.Set(ColumnChanges.Unique); } }
private static void CheckNullable(Column old, Column @new, ColumnMetaChange metaChange) { // Check if changed to non-nullable if (old.IsNullable && [email protected]) { metaChange.Set(ColumnChanges.NonNull); } else if (!old.IsNullable && @new.IsNullable) { metaChange.Set(ColumnChanges.Nullable); } }
private static void CheckDatatypeString(Column old, Column @new, ColumnMetaChange metaChange) { if (old.CharacterMaxLength != @new.CharacterMaxLength) { metaChange.Set(ColumnChanges.Length); } }
private static void CheckDatatypeInteger(Column old, Column @new, ColumnMetaChange metaChange) { if (old.Precision != @new.Precision) { metaChange.Set(ColumnChanges.Length); } }
// TODO: Not near all necessary checks are made. We have to decide how much to track and which flags to set on said changes. private static void CheckDatatype(Column old, Column @new, ColumnMetaChange metaChange) { if (old.DataType != @new.DataType) { metaChange.Set(ColumnChanges.DataType); } switch (@new.DataType) { // Integers case SqlDataType.TinyInt: case SqlDataType.SmallInt: case SqlDataType.Int: case SqlDataType.BigInt: CheckDatatypeInteger(old, @new, metaChange); break; // Strings/chars case SqlDataType.Char: case SqlDataType.NChar: case SqlDataType.NText: case SqlDataType.NVarChar: case SqlDataType.NVarCharMax: case SqlDataType.Text: case SqlDataType.VarChar: case SqlDataType.VarCharMax: CheckDatatypeString(old, @new, metaChange); break; // Date and time case SqlDataType.SmallDateTime: case SqlDataType.Timestamp: case SqlDataType.Date: case SqlDataType.Time: case SqlDataType.DateTimeOffset: case SqlDataType.DateTime2: case SqlDataType.DateTime: break; // Bit/binary case SqlDataType.VarBinaryMax: case SqlDataType.VarBinary: case SqlDataType.Binary: case SqlDataType.Bit: break; // Float/decimal case SqlDataType.Float: case SqlDataType.Decimal: break; // Money / precise case SqlDataType.Real: case SqlDataType.SmallMoney: case SqlDataType.Numeric: case SqlDataType.Money: break; } }
private static void CheckRename(Column old, Column @new, ColumnMetaChange metaChange) { if (!old.Name.Equals(@new.Name)) { metaChange.Set(ColumnChanges.Rename); } }
private static void CheckDeletion(Column old, Column @new, ColumnMetaChange metaChange) { if (@new == null) { metaChange.Set(ColumnChanges.Deletion); } }
private static void CheckAddition(Column old, Column @new, ColumnMetaChange metaChange) { if (old == null) { metaChange.Set(ColumnChanges.Addition); } }