//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(); } }
internal void AddAlteredObject(DatabaseObjectInfo obj) { if (obj.GroupId != null) { alteredObjects.Add(obj.GroupId); } }
protected DatabaseObjectInfo GetPossibleTableObject(DatabaseObjectInfo newObject) { if (ParentTable != null) { DatabaseObjectInfo res = newObject.CloneObject(null); ((TableObjectInfo)res).SetDummyTable(ParentTable.FullName); return(res); } else { return(newObject); } }
// 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 }); }
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; //} }
//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(); }
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); } }
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); } }
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; //} }
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, }); } }
public override void ChangeStructure(DatabaseInfo s) { base.ChangeStructure(s); OldObject = s.FindByGroupId(OldObject.GroupId) as DatabaseObjectInfo; }
public override void AssignFrom(AlterOperation src) { base.AssignFrom(src); OldObject = ((AlterOperation_Rename)src).OldObject; NewName = ((AlterOperation_Rename)src).NewName; }
public override void AssignFrom(AlterOperation src) { base.AssignFrom(src); NewObject = ((AlterOperation_Create)src).NewObject; }
public override void AssignFrom(AlterOperation src) { base.AssignFrom(src); OldObject = ((AlterOperation_Drop)src).OldObject; }
private void PairObjects(DatabaseObjectInfo src, DatabaseObjectInfo dst) { _dstGroupIds.Remove(dst.GroupId); dst.GroupId = src.GroupId; _dstGroupIds[dst.GroupId] = dst; }
public bool IsPaired(DatabaseObjectInfo obj) { return(_srcGroupIds.ContainsKey(obj.GroupId) && _dstGroupIds.ContainsKey(obj.GroupId)); }
public bool IsAltered(DatabaseObjectInfo obj) { return(alteredObjects.Contains(obj.GroupId)); }
public override void AssignFrom(AlterOperation src) { base.AssignFrom(src); OldObject = ((AlterOperation_Change)src).OldObject; NewObject = ((AlterOperation_Change)src).NewObject; }