Exemple #1
0
 public override void TransformToImplementedOps(AlterProcessorCaps caps, DbDiffOptions opts, List <AlterOperation> replacement, AlterPlan plan, IDatabaseSource targetDb)
 {
     if (!caps[((ISpecificObjectStructure)OldObject).ObjectType].Change)
     {
         plan.RecreateObject(OldObject, NewObject);
         replacement.Clear();
     }
 }
Exemple #2
0
        public override void AddPhysicalDependencies(AlterProcessorCaps caps, DbDiffOptions opts, List <AlterOperation> before, List <AlterOperation> after, AlterPlan plan, IDatabaseSource targetDb)
        {
            var oldcol = OldObject as ColumnStructure;

            if (caps.DepCaps.ChangeColumn_Constraint || caps.DepCaps.ChangeColumn_Index)
            {
                ParentTable.LoadStructure(TableStructureMembers.Constraints, targetDb);
                foreach (var cnt in ParentTable.Constraints)
                {
                    var cc = cnt as ColumnsConstraint;
                    if (cc == null)
                    {
                        continue;
                    }
                    if (cc.Columns.Any(c => c.ColumnName == oldcol.ColumnName))
                    {
                        if (
                            (cc is IIndex && caps.DepCaps.ChangeColumn_Index) ||
                            (!(cc is IIndex) && caps.DepCaps.ChangeColumn_Constraint))
                        {
                            plan.RecreateObject(cc, null);
                        }
                    }
                }
            }
            if (caps.DepCaps.ChangeColumn_Reference)
            {
                ParentTable.LoadStructure(TableStructureMembers.ReferencedFrom, targetDb);

                foreach (ForeignKey fk in ParentTable.GetReferencedFrom())
                {
                    for (int i = 0; i < fk.PrimaryKeyColumns.Count; i++)
                    {
                        if (fk.PrimaryKeyColumns[i].ColumnName == oldcol.ColumnName)
                        {
                            plan.RecreateObject(fk, null);
                        }
                    }
                }
            }
        }
Exemple #3
0
        protected void TransformToRecreateTable(List <AlterOperation> replacement, AlterPlan plan, IDatabaseSource targetDb)
        {
            replacement.Clear();
            var op = new AlterOperation_RecreateTable {
                ParentTable = ParentTable
            };

            ParentTable.LoadStructure(TableStructureMembers.All, targetDb);
            foreach (var fk in ParentTable.GetReferencedFrom())
            {
                plan.RecreateObject(fk as AbstractObjectStructure, null);
            }
            op.AppendOp(this);
            replacement.Add(op);
        }
Exemple #4
0
        public override void TransformToImplementedOps(AlterProcessorCaps caps, DbDiffOptions opts, List <AlterOperation> replacement, AlterPlan plan, IDatabaseSource targetDb)
        {
            var c = GetConstraintCaps(caps, NewObject);

            if (!c.Change)
            {
                if (c.Create && c.Drop)
                {
                    plan.RecreateObject(OldObject, NewObject);
                    replacement.Clear();
                }
                else
                {
                    TransformToRecreateTable(replacement, plan, targetDb);
                }
            }
        }