コード例 #1
0
        //RenameSpecificObject

        public static void RenameObject(this IAlterProcessor proc, DatabaseObjectInfo obj, DbDiffOptions opts, NameWithSchema newName)
        {
            bool renameOk = false;
            //var dom = obj as IDomainStructure;
            //if (dom != null)
            //{
            //    renameOk = DbDiffTool.GenerateRename(dom.FullName, newName,
            //        (old, sch) => proc.ChangeDomainSchema(old, sch),
            //        (old, nam) => proc.RenameDomain(old, nam),
            //        proc.AlterCaps.ChangeTableSchema, proc.AlterCaps.RenameDomain, opts);
            //}
            var tbl = obj as TableInfo;

            if (tbl != null)
            {
                renameOk = DbDiffTool.GenerateRename(tbl.FullName, newName,
                                                     (old, sch) => proc.ChangeTableSchema(new TableInfo(null)
                {
                    FullName = old
                }, sch),
                                                     (old, nam) => proc.RenameTable(new TableInfo(null)
                {
                    FullName = old
                }, nam),
                                                     proc.AlterCaps.ChangeTableSchema, proc.AlterCaps.RenameTable, opts);
            }
            var col = obj as ColumnInfo;

            if (col != null)
            {
                if (proc.AlterCaps.RenameColumn)
                {
                    proc.RenameColumn(col, newName.Name);
                    renameOk = true;
                }
            }
            var cnt = obj as ConstraintInfo;

            if (cnt != null)
            {
                if (proc.AlterCaps.RenameConstraint)
                {
                    proc.RenameConstraint(cnt, newName.Name);
                    renameOk = true;
                }
            }
            var spec = obj as SpecificObjectInfo;

            if (spec != null)
            {
                renameOk = DbDiffTool.GenerateRenameSpecificObject(spec, newName,
                                                                   (old, sch) => proc.ChangeSpecificObjectSchema(old, sch),
                                                                   (old, nam) => proc.RenameSpecificObject(old, nam),
                                                                   proc.AlterCaps.GetSpecificObjectCaps(spec.ObjectType).ChangeSchema, proc.AlterCaps.GetSpecificObjectCaps(spec.ObjectType).Rename, opts);
            }
            if (!renameOk)
            {
                throw new AlterNotPossibleError();
            }
        }
コード例 #2
0
 internal void AddAlteredObject(DatabaseObjectInfo obj)
 {
     if (obj.GroupId != null)
     {
         alteredObjects.Add(obj.GroupId);
     }
 }
コード例 #3
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 protected DatabaseObjectInfo GetPossibleTableObject(DatabaseObjectInfo newObject)
 {
     if (ParentTable != null)
     {
         DatabaseObjectInfo res = newObject.CloneObject(null);
         ((TableObjectInfo)res).SetDummyTable(ParentTable.FullName);
         return(res);
     }
     else
     {
         return(newObject);
     }
 }
コード例 #4
0
ファイル: AlterPlan.cs プロジェクト: timothydodd/dbshell
        // this structure is incrementally loaded, when needed
        //int m_fixedOrderCounter = 0;

        public void RecreateObject(DatabaseObjectInfo recreatedObject, DatabaseObjectInfo newVersion)
        {
            foreach (var it in RecreatedItems)
            {
                if (it.RecreatedObject == recreatedObject)
                {
                    if (it.NewVersion != null && newVersion != null)
                    {
                        throw new InternalError("DBSH-00140 Two new versions of object " + recreatedObject.ToString());
                    }
                    it.NewVersion = newVersion ?? it.NewVersion;
                    return;
                }
            }
            RecreatedItems.Add(new RecreatedItem {
                RecreatedObject = recreatedObject, NewVersion = newVersion
            });
        }
コード例 #5
0
        public static void CreateObject(this IAlterProcessor proc, DatabaseObjectInfo obj)
        {
            var tbl = obj as TableInfo;

            if (tbl != null)
            {
                proc.CreateTable(tbl);
                return;
            }
            var col = obj as ColumnInfo;

            if (col != null)
            {
                proc.CreateColumn(col);
                return;
            }
            var cnt = obj as ConstraintInfo;

            if (cnt != null)
            {
                proc.CreateConstraint(cnt);
                return;
            }
            var spe = obj as SpecificObjectInfo;

            if (spe != null)
            {
                proc.CreateSpecificObject(spe);
                return;
            }
            //var sch = obj as ISchemaStructure;
            //if (sch != null)
            //{
            //    proc.CreateSchema(sch);
            //    return;
            //}
            //var dom = obj as IDomainStructure;
            //if (dom != null)
            //{
            //    proc.CreateDomain(dom);
            //    return;
            //}
        }
コード例 #6
0
ファイル: DbDiffActions.cs プロジェクト: timothydodd/dbshell
        //public bool SourceColumnNullable
        //{
        //    get
        //    {
        //        WantInfo();
        //        if (m_srcObject != null) return ((IColumnStructure)m_srcObject).IsNullable;
        //        return false;
        //    }
        //}
        //public bool TargetColumnNullable
        //{
        //    get
        //    {
        //        WantInfo();
        //        if (m_dstObject != null) return ((IColumnStructure)m_dstObject).IsNullable;
        //        return false;
        //    }
        //}
        //public string SourceColumnType
        //{
        //    get
        //    {
        //        WantInfo();
        //        if (m_srcObject != null) return m_diff.Source.Dialect.GenericTypeToSpecific(((IColumnStructure)m_srcObject).DataType).ToString();
        //        return "";
        //    }
        //}
        //public string TargetColumnType
        //{
        //    get
        //    {
        //        WantInfo();
        //        if (m_dstObject != null) return m_diff.Target.Dialect.GenericTypeToSpecific(((IColumnStructure)m_dstObject).DataType).ToString();
        //        return "";
        //    }
        //}
        //public string ConstraintType
        //{
        //    get
        //    {
        //        WantInfo();
        //        return m_anyObject.GetName().ObjectType.ToString();
        //    }
        //}
        //public string SourceConstraintColumns
        //{
        //    get
        //    {
        //        var cnt = m_srcObject as ColumnsConstraintInfo;
        //        if (cnt != null) return cnt.Columns.GetNames().CreateDelimitedText(",");
        //        return null;
        //    }
        //}
        //public string TargetConstraintColumns
        //{
        //    get
        //    {
        //        var cnt = m_dstObject as ColumnsConstraintInfo;
        //        if (cnt != null) return cnt.Columns.GetNames().CreateDelimitedText(",");
        //        return null;
        //    }
        //}
        //public string ActionSqlTitle
        //{
        //    get
        //    {
        //        if (Operation != null) return Operation.ToString();
        //        return null;
        //    }
        //}

        private void WantInfo()
        {
            if (m_anyObject != null)
            {
                return;
            }
            if (GroupId == null)
            {
                return;
            }
            m_srcObject = m_diff.FindSource(GroupId);
            m_dstObject = m_diff.FindTarget(GroupId);
            m_anyObject = m_srcObject ?? m_dstObject;
            //Errors.CheckNotNull("DAE-00364", m_anyObject);
            m_srcName = m_srcObject != null?m_srcObject.GetName() : null;

            m_dstName = m_dstObject != null?m_dstObject.GetName() : null;

            var name = m_anyObject.GetName();
        }
コード例 #7
0
ファイル: AlterPlan.cs プロジェクト: timothydodd/dbshell
        public void RecreateObject_Drop(DatabaseObjectInfo obj)
        {
            var cnt = obj as ConstraintInfo;

            if (cnt != null)
            {
                DropConstraint(cnt, PlanPosition.Begin);
            }
            var spec = obj as SpecificObjectInfo;

            if (spec != null)
            {
                DropSpecificObject(spec, PlanPosition.Begin);
            }
            var col = obj as ColumnInfo;

            if (col != null)
            {
                DropColumn(col, PlanPosition.Begin);
            }
        }
コード例 #8
0
ファイル: AlterPlan.cs プロジェクト: timothydodd/dbshell
        public void RecreateObject_Create(DatabaseObjectInfo recreated, DatabaseObjectInfo newobj)
        {
            var cnt = newobj as ConstraintInfo;

            if (cnt != null)
            {
                CreateConstraint(((ConstraintInfo)recreated).OwnerTable, cnt, PlanPosition.End);
            }
            var spec = newobj as SpecificObjectInfo;

            if (spec != null)
            {
                CreateSpecificObject(spec, PlanPosition.End);
            }
            var col = newobj as ColumnInfo;

            if (col != null)
            {
                CreateColumn(((ColumnInfo)recreated).OwnerTable, col, PlanPosition.End);
            }
        }
コード例 #9
0
        public static void ChangeObject(this IAlterProcessor proc, DatabaseObjectInfo obj, DatabaseObjectInfo newObj)
        {
            var tbl = obj as TableInfo;

            if (tbl != null)
            {
                throw new AlterNotPossibleError();
            }
            var col = obj as ColumnInfo;

            if (col != null)
            {
                proc.ChangeColumn(col, (ColumnInfo)newObj);
                return;
            }
            //var cnt = obj as ConstraintInfo;
            //if (cnt != null)
            //{
            //    proc.ChangeConstraint(cnt, (IConstraint) newObj);
            //    return;
            //}
            //var spe = obj as ISpecificObjectStructure;
            //if (spe != null)
            //{
            //    proc.ChangeSpecificObject(spe, (ISpecificObjectStructure) newObj);
            //    return;
            //}
            //var sch = obj as ISchemaStructure;
            //if (sch != null)
            //{
            //    proc.ChangeSchema(sch, (ISchemaStructure) newObj);
            //    return;
            //}
            //var dom = obj as IDomainStructure;
            //if (dom != null)
            //{
            //    proc.ChangeDomain(dom, (IDomainStructure) newObj);
            //    return;
            //}
        }
コード例 #10
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 protected static ObjectOperationCaps GetConstraintCaps(AlterProcessorCaps caps, DatabaseObjectInfo obj)
 {
     if (obj is IndexInfo)
     {
         return(new ObjectOperationCaps
         {
             Create = caps.AddIndex,
             Drop = caps.DropIndex,
             Rename = caps.RenameIndex,
             Change = caps.ChangeIndex,
         });
     }
     else
     {
         return(new ObjectOperationCaps
         {
             Create = caps.AddConstraint,
             Drop = caps.DropConstraint,
             Rename = caps.RenameConstraint,
             Change = caps.ChangeConstraint,
         });
     }
 }
コード例 #11
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 public override void ChangeStructure(DatabaseInfo s)
 {
     base.ChangeStructure(s);
     OldObject = s.FindByGroupId(OldObject.GroupId) as DatabaseObjectInfo;
 }
コード例 #12
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 public override void AssignFrom(AlterOperation src)
 {
     base.AssignFrom(src);
     OldObject = ((AlterOperation_Rename)src).OldObject;
     NewName   = ((AlterOperation_Rename)src).NewName;
 }
コード例 #13
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 public override void AssignFrom(AlterOperation src)
 {
     base.AssignFrom(src);
     NewObject = ((AlterOperation_Create)src).NewObject;
 }
コード例 #14
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 public override void AssignFrom(AlterOperation src)
 {
     base.AssignFrom(src);
     OldObject = ((AlterOperation_Drop)src).OldObject;
 }
コード例 #15
0
 private void PairObjects(DatabaseObjectInfo src, DatabaseObjectInfo dst)
 {
     _dstGroupIds.Remove(dst.GroupId);
     dst.GroupId = src.GroupId;
     _dstGroupIds[dst.GroupId] = dst;
 }
コード例 #16
0
 public bool IsPaired(DatabaseObjectInfo obj)
 {
     return(_srcGroupIds.ContainsKey(obj.GroupId) && _dstGroupIds.ContainsKey(obj.GroupId));
 }
コード例 #17
0
 public bool IsAltered(DatabaseObjectInfo obj)
 {
     return(alteredObjects.Contains(obj.GroupId));
 }
コード例 #18
0
ファイル: AlterOps.cs プロジェクト: timothydodd/dbshell
 public override void AssignFrom(AlterOperation src)
 {
     base.AssignFrom(src);
     OldObject = ((AlterOperation_Change)src).OldObject;
     NewObject = ((AlterOperation_Change)src).NewObject;
 }