Esempio n. 1
0
        public override void Perform(SchemaChanges changes, IOutput output)
        {
            // This step covers both unique keys (including primary keys) and non-unique indexes
            foreach (var desired in UniqueIndexType.AllFrom(changes.Desired))
            {
                if (changes.Current.Contains(desired))
                {
                    continue;
                }

                var sql = changes.SchemaDriver.GetCreateUniqueConstraintSql(desired.ParentName, desired.State.IsPrimaryKey, desired.Name,
                                                                            desired.State.IndexState.FieldNames, desired.State.IndexState.CustomState);
                changes.Put(sql, desired);
            }
            foreach (var desired in NonUniqueIndexType.AllFrom(changes.Desired))
            {
                if (changes.Current.Contains(desired))
                {
                    continue;
                }

                var sql = changes.SchemaDriver.GetCreateIndexSql(desired.ParentName, desired.Name, desired.State.FieldNames, desired.State.CustomState);
                changes.Put(sql, desired);
            }
        }
Esempio n. 2
0
        public override void Perform(SchemaChanges changes, IOutput output)
        {
            // This step covers both unique keys (including primary keys) and non-unique indexes
            foreach (var current in UniqueIndexType.AllFrom(changes.Current))
            {
                if (!UniqueIndexType.IndexHasChanged(changes, current))
                {
                    continue;
                }

                changes.Remove(changes.SchemaDriver.GetDropUniqueConstraintSql(current.ParentName, current.Name), current);
            }
            foreach (var current in NonUniqueIndexType.AllFrom(changes.Current))
            {
                if (!NonUniqueIndexType.IndexHasChanged(changes, current))
                {
                    continue;
                }

                changes.Remove(changes.SchemaDriver.GetDropIndexSql(current.ParentName, current.Name), current);
            }
        }