public static void CreateSpecificObject(this IAlterProcessor proc, SpecificObjectInfo obj) { var view = obj as ViewInfo; if (view != null) { proc.CreateView(view); } var sp = obj as StoredProcedureInfo; if (sp != null) { proc.CreateStoredProcedure(sp); } var func = obj as FunctionInfo; if (func != null) { proc.CreateFunction(func); } var trg = obj as TriggerInfo; if (trg != null) { proc.CreateTrigger(trg); } }
//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(); } }
public static void DropConstraint(this IAlterProcessor proc, ConstraintInfo cnt) { var pk = cnt as PrimaryKeyInfo; if (pk != null) { proc.DropPrimaryKey(pk); } var fk = cnt as ForeignKeyInfo; if (fk != null) { proc.DropForeignKey(fk); } var uq = cnt as UniqueInfo; if (uq != null) { proc.DropUnique(uq); } var ix = cnt as IndexInfo; if (ix != null) { proc.DropIndex(ix); } var ch = cnt as CheckInfo; if (ch != null) { proc.DropCheck(ch); } }
public static void DropSpecificObject(this IAlterProcessor proc, SpecificObjectInfo obj) { var view = obj as ViewInfo; if (view != null) { proc.DropView(view, true); } var sp = obj as StoredProcedureInfo; if (sp != null) { proc.DropStoredProcedure(sp, true); } var func = obj as FunctionInfo; if (func != null) { proc.DropFunction(func, true); } var trg = obj as TriggerInfo; if (trg != null) { proc.DropTrigger(trg, true); } }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { base.Run(proc, opts); if (Data != null) { proc.UpdateData((TableStructure)NewObject, Data, null); } }
public static void RenameObject(this IAlterProcessor proc, IAbstractObjectStructure 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 ITableStructure; if (tbl != null) { renameOk = DbDiffTool.GenerateRename(tbl.FullName, newName, (old, sch) => proc.ChangeTableSchema(old, sch), (old, nam) => proc.RenameTable(old, nam), proc.AlterCaps.ChangeTableSchema, proc.AlterCaps.RenameTable, opts); } var col = obj as IColumnStructure; if (col != null) { if (proc.AlterCaps.RenameColumn) { proc.RenameColumn(col, newName.Name); renameOk = true; } } var cnt = obj as IConstraint; if (cnt != null) { if (proc.AlterCaps.RenameConstraint) { proc.RenameConstraint(cnt, newName.Name); renameOk = true; } } var spec = obj as ISpecificObjectStructure; if (spec != null) { renameOk = DbDiffTool.GenerateRenameSpecificObject(spec, newName, (old, sch) => proc.ChangeSpecificObjectSchema(old, sch), (old, nam) => proc.RenameSpecificObject(old, nam), proc.AlterCaps[spec.ObjectType].ChangeSchema, proc.AlterCaps[spec.ObjectType].Rename, opts); } if (!renameOk) { throw new AlterNotPossibleError(); } }
/// alters table, decomposes to alter actions; doesn't transform alter plan /// proc must be able to run all logical operations public static void DecomposeAlterTable(this IAlterProcessor proc, ITableStructure oldTable, ITableStructure newTable, DbDiffOptions options) { DbObjectPairing pairing = CreateTablePairing(oldTable, newTable); // decompose to alter actions AlterPlan plan = new AlterPlan(); AlterTable(plan, oldTable, newTable, options, pairing); var run = plan.CreateRunner(); run.Run(proc, options); }
public static void CreateConstraints(this IAlterProcessor fmt, IEnumerable constraints) { if (constraints == null) { return; } foreach (IConstraint cnt in constraints) { fmt.CreateConstraint(cnt); } }
public static void CreateConstraints(this IAlterProcessor proc, IEnumerable constraints) { if (constraints == null) { return; } foreach (ConstraintInfo cnt in constraints) { proc.CreateConstraint(cnt); } }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { var newtbl = new TableStructure(ParentTable); var dbs = new DatabaseStructure(); dbs.Tables.Add(newtbl); foreach (var op in AlterTableOps) { op.Run(dbs, opts); } proc.RecreateTable(ParentTable, newtbl); opts.AlterLogger.Info(Texts.Get("s_recreated$table", "table", ParentTable.FullName)); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { var newtbl = ParentTable.CloneTable(); var dbs = new DatabaseInfo(); dbs.Tables.Add(newtbl); foreach (var op in AlterTableOps) { op.Run(new DatabaseInfoAlterProcessor(dbs), opts); } proc.RecreateTable(ParentTable, newtbl); opts.AlterLogger.Info(String.Format("Recreated table {0}", ParentTable.FullName)); }
public static void AlterDatabase(this IAlterProcessor proc, DatabaseInfo src, DatabaseInfo dst, DatabaseInfo targetDb, DbDiffOptions opts, Action <AlterPlan> extendPlan) { AlterPlan plan = new AlterPlan(targetDb); DbDiffTool.AlterDatabase(plan, src, dst, opts); if (extendPlan != null) { extendPlan(plan); } plan.Transform(proc.AlterCaps, opts); var run = plan.CreateRunner(); run.Run(proc, opts); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { base.Run(proc, opts); if (Data != null) { if (Data.MainChanges != null) { proc.UpdateData((TableInfo)NewObject, Data.MainChanges, null); } if (Data.LinkedChanges != null) { proc.UpdateData(Data.LinkedChanges, null); } } }
public static void DropObject(this IAlterProcessor proc, IAbstractObjectStructure obj) { var tbl = obj as ITableStructure; if (tbl != null) { proc.DropTable(tbl); return; } var col = obj as IColumnStructure; if (col != null) { proc.DropColumn(col); return; } var cnt = obj as IConstraint; if (cnt != null) { proc.DropConstraint(cnt); return; } var spe = obj as ISpecificObjectStructure; if (spe != null) { proc.DropSpecificObject(spe); return; } var sch = obj as ISchemaStructure; if (sch != null) { proc.DropSchema(sch); return; } var dom = obj as IDomainStructure; if (dom != null) { proc.DropDomain(dom); return; } }
public static void ChangeObject(this IAlterProcessor proc, IAbstractObjectStructure obj, IAbstractObjectStructure newObj) { var tbl = obj as ITableStructure; if (tbl != null) { throw new AlterNotPossibleError(); } var col = obj as IColumnStructure; if (col != null) { proc.ChangeColumn(col, (IColumnStructure)newObj); return; } var cnt = obj as IConstraint; 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; } }
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 void Run(IAlterProcessor proc, DbDiffOptions opts) { //foreach (var dep in RecreatedItems) //{ // opts.AlterLogger.Info(Texts.Get("s_recreated_object$object", "object", dep.RecreatedObject)); //} //foreach (var cls in RecreatedItem.DropClassOrder) //{ // foreach (var dep in RecreatedItems) // { // if (dep.ItemClass != cls) continue; // dep.RunDrop(proc, opts); // } //} var dmp = proc as ISqlDumper; if (dmp != null) { dmp.AlterProlog(); dmp.BeginTransaction(); } foreach (var op in Operations) { op.Run(proc, opts); using (DbDiffChangeLoggerContext ctx = new DbDiffChangeLoggerContext(opts, NopMessageLogger.Instance, DbDiffOptsLogger.AlterLogger)) { if (op.MustRunOnParalelStructure()) { // run operation paralel on Structure, so that we have actual object names op.Run(new DatabaseInfoAlterProcessor(Structure), opts); } } } if (dmp != null) { dmp.CommitTransaction(); dmp.AlterEpilog(); } }
public void Run(IAlterProcessor proc, DbDiffOptions opts) { //foreach (var dep in RecreatedItems) //{ // opts.AlterLogger.Info(Texts.Get("s_recreated_object$object", "object", dep.RecreatedObject)); //} //foreach (var cls in RecreatedItem.DropClassOrder) //{ // foreach (var dep in RecreatedItems) // { // if (dep.ItemClass != cls) continue; // dep.RunDrop(proc, opts); // } //} foreach (var op in Operations) { op.Run(proc, opts); using (DbDiffChangeLoggerContext ctx = new DbDiffChangeLoggerContext(opts, NopLogger.Instance, DbDiffOptsLogger.AlterLogger)) { if (op.MustRunOnParalelStructure()) { // run operation paralel on Structure, so that we have actual object names op.Run(Structure, opts); } } } //foreach (var cls in RecreatedItem.CreateClassOrder) //{ // foreach (var dep in RecreatedItems) // { // if (dep.ItemClass != cls) continue; // if (Structure.FindByGroupId(dep.RecreatedObject.GroupId) == null) // { // // object was dropped // continue; // } // dep.RunCreate(proc, opts); // } //} }
public static void ChangeSpecificObjectSchema(this IAlterProcessor proc, SpecificObjectInfo obj, string newSchema) { var view = obj as ViewInfo; if (view != null) { proc.ChangeViewSchema(view, newSchema); } var sp = obj as StoredProcedureInfo; if (sp != null) { proc.ChangeStoredProcedureSchema(sp, newSchema); } var func = obj as FunctionInfo; if (func != null) { proc.ChangeFunctionSchema(func, newSchema); } }
public static void RenameSpecificObject(this IAlterProcessor proc, SpecificObjectInfo obj, string newName) { var view = obj as ViewInfo; if (view != null) { proc.RenameView(view, newName); } var sp = obj as StoredProcedureInfo; if (sp != null) { proc.RenameStoredProcedure(sp, newName); } var func = obj as FunctionInfo; if (func != null) { proc.RenameFunction(func, newName); } }
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; //} }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { //proc.AlterDatabaseOptions(DbName, Options); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { //proc.ReorderColumns(ParentTable.FullName, NewColumnOrder); }
public static void ChangeColumn(this IAlterProcessor proc, ColumnInfo oldcol, ColumnInfo newcol) { proc.ChangeColumn(oldcol, newcol, null); }
public static void CreateColumn(this IAlterProcessor proc, ColumnInfo col) { proc.CreateColumn(col, null); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { //proc.CustomAction(Query); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { proc.RenameObject(OldObject, opts, NewName); }
public abstract void Run(IAlterProcessor proc, DbDiffOptions opts);
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { //proc.AlterTableOptions(ParentTable, Options); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { //proc.UpdateData(ParentTable, Script, null); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { proc.DropObject(OldObject); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { base.Run(proc, opts); if (Data != null) { if (Data.MainChanges != null) proc.UpdateData((TableInfo) NewObject, Data.MainChanges, null); if (Data.LinkedChanges != null) proc.UpdateData(Data.LinkedChanges, null); } }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { proc.ChangeColumn((ColumnInfo)OldObject, (ColumnInfo)GetPossibleTableObject(NewObject), AdditionalConstraints); }
public static void AlterDatabase(this IAlterProcessor proc, DatabaseInfo src, DatabaseInfo dst, DatabaseInfo targetDb, DbDiffOptions opts) { proc.AlterDatabase(src, dst, targetDb, opts, null); }
public override void Run(IAlterProcessor proc, DbDiffOptions opts) { proc.ChangeObject(OldObject, GetPossibleTableObject(NewObject)); }
public void Run(IAlterProcessor proc, DbDiffOptions opts) { //foreach (var dep in RecreatedItems) //{ // opts.AlterLogger.Info(Texts.Get("s_recreated_object$object", "object", dep.RecreatedObject)); //} //foreach (var cls in RecreatedItem.DropClassOrder) //{ // foreach (var dep in RecreatedItems) // { // if (dep.ItemClass != cls) continue; // dep.RunDrop(proc, opts); // } //} foreach (var op in Operations) { op.Run(proc, opts); using (DbDiffChangeLoggerContext ctx = new DbDiffChangeLoggerContext(opts, NopMessageLogger.Instance, DbDiffOptsLogger.AlterLogger)) { if (op.MustRunOnParalelStructure()) { // run operation paralel on Structure, so that we have actual object names op.Run(new DatabaseInfoAlterProcessor(Structure), opts); } } } }