public override void OnSchemaReady()
        {
            if (UpgradeContext.Stage == UpgradeStage.Upgrading)
            {
                var schemaHints  = UpgradeContext.SchemaHints;
                var storageModel = (StorageModel)schemaHints.SourceModel;

                foreach (var table in storageModel.Tables)
                {
                    foreach (var index in table.SecondaryIndexes)
                    {
                        var name = index.Name;
                        if (!name.StartsWith(CustomIndexPrefix))
                        {
                            continue;
                        }
                        var ignoreHint = new IgnoreHint(index.Path);
                        schemaHints.Add(ignoreHint);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Visits specified <see cref="Node"/> objects.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <returns>
        /// Difference between <paramref name="source"/>
        /// and <paramref name="target"/> objects.
        /// <see langword="null"/>, if they're equal.
        /// </returns>
        /// <exception cref="InvalidOperationException">Both source and target are <see langword="null" />.</exception>
        /// <exception cref="NullReferenceException">Current difference is not <see cref="NodeDifference"/>.</exception>
        protected virtual Difference VisitNode(Node source, Node target)
        {
            using (TryActivate(source, target, (s, t) => new NodeDifference(s, t))) {
                IgnoreHint ignoreHint = null;
                if (source != null)
                {
                    ignoreHint = Hints.GetHint <IgnoreHint>(source);
                }
                if (ignoreHint != null)
                {
                    return(null);
                }

                var context    = Context;
                var difference = (NodeDifference)context.Difference;
                if (difference == null)
                {
                    throw new NullReferenceException();
                }
                var any = source ?? target;
                if (any == null)
                {
                    throw Exceptions.InternalError(Strings.ExBothSourceAndTargetAreNull, CoreLog.Instance);
                }


                bool isNewDifference = TryRegisterDifference(source, target, difference);
                if (isNewDifference)
                {
                    // Build movement info
                    difference.MovementInfo = BuildMovementInfo(source, target);
                    // Detect data changes
                    difference.IsDataChanged = HasDataChangeHint(difference.Source);
                }

                difference.PropertyChanges.Clear();

                // Compare properties
                CompareProperties(source, target, difference);

                // Check if remove on cleanup
                if (difference.IsRemoved)
                {
                    var nodeProperties = GetPropertyDifferences(difference);
                    difference.IsRemoveOnCleanup = HasDependencies(source) ||
                                                   nodeProperties.Any(nodeProperty => nodeProperty.IsRemoveOnCleanup);
                }
                var recreated = MovementInfo.Created | MovementInfo.Removed;
                if (Stage == ComparisonStage.ReferenceComparison && source != null && target != null)
                {
                    if ((difference.MovementInfo & recreated) != recreated)
                    {
                        var propertyAccessors = difference.PropertyChanges
                                                .Where(p => p.Value.Source != null && p.Value.Target != null)
                                                .Select(p => new { Pair = p, NodeDifference = p.Value as NodeDifference })
                                                .Where(a => a.NodeDifference != null && !a.NodeDifference.IsNameChanged)
                                                .Select(a => source.PropertyAccessors[a.Pair.Key])
                                                .ToList();
                        if (propertyAccessors.Count != 0 && propertyAccessors.Any(propertyAccessor => propertyAccessor.RecreateParent))
                        {
                            difference.MovementInfo = recreated;
                        }
                    }
                }

                return(difference.HasChanges ? difference : null);
            }
        }