コード例 #1
0
        public static bool IndexHasChanged(SchemaChanges changes, SubObjectState <UniqueIndexType, UniqueIndexType.State> current)
        {
            if (current == null)
            {
                return(true);
            }

            var desired = changes.Desired.Get(current);

            // The index doesn't exist in the desired schema at all
            if (desired == null)
            {
                return(true);
            }

            // It's changed from primary key to not or vice versa
            if (desired.State.IsPrimaryKey != current.State.IsPrimaryKey)
            {
                return(true);
            }

            // The index fields are different
            if (IndexState.IndexStateHasChanged(changes, current.ParentIdentifier, current.State.IndexState, desired.State.IndexState))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        internal static bool IndexStateHasChanged(SchemaChanges changes, Identifier table, IndexState current, IndexState desired)
        {
            // The table might need to be dropped entirely to reorder the columns
            if (FieldType.IsFieldReorderPossiblyNeeded(changes, table))
            {
                return(true);
            }

            // The sequence of field names don't match
            if (!Enumerable.SequenceEqual(desired.FieldNames, current.FieldNames, changes.DbDriver.DbStringComparer))
            {
                return(true);
            }

            // Something custom about the index has changed
            if (!changes.SchemaDriver.IsIndexCustomStateEqual(current.CustomState, desired.CustomState))
            {
                return(true);
            }

            // Any of the fields in the index are changing
            if (current.Fields.Any(field => FieldType.FieldHasChanged(changes, table, field)))
            {
                return(true);
            }

            return(false);
        }
コード例 #3
0
 public State(bool isPrimaryKey, IEnumerable <Identifier> fields, IndexCustomState customState)
 {
     this.isPrimaryKey = isPrimaryKey;
     this.indexState   = new IndexState(fields, customState);
 }