public static DbObjectPairing CreateTablePairing(TableInfo oldTable, TableInfo newTable) { var src = new DatabaseInfo(); var dst = src.CloneDatabase(); src.AddObject(oldTable, true); dst.AddObject(newTable, true); DbObjectPairing pairing = new DbObjectPairing(src, dst); return(pairing); }
public DatabaseDiff(DatabaseInfo src, DatabaseInfo dst, DbDiffOptions options, IDatabaseFactory factory) { _factory = factory; _src = src.CloneDatabase(); _dst = dst.CloneDatabase(); _actions = new DbDiffAction(this); //m_actions = new DiffActionDatabase(this, m_src, m_dst); _options = options; RebuildGroupIdDictionary(); if (_src.GroupId != _dst.GroupId) CreatePairing(); CreateActions(); }
public DatabaseDiff(DatabaseInfo src, DatabaseInfo dst, DbDiffOptions options, IDatabaseFactory factory) { _factory = factory; _src = src.CloneDatabase(); _dst = dst.CloneDatabase(); _actions = new DbDiffAction(this); //m_actions = new DiffActionDatabase(this, m_src, m_dst); _options = options; RebuildGroupIdDictionary(); if (_src.GroupId != _dst.GroupId) { CreatePairing(); } CreateActions(); }
public AlterPlanBase(DatabaseInfo db) { Structure = db.CloneDatabase(); }
private void TestDiff(Action<DatabaseInfo> mangle, string expectedResult) { var db1 = new DatabaseInfo(); var t1 = new TableInfo(db1) { Name = "t1", Schema = "dbo", }; t1.Columns.Add(new ColumnInfo(t1) { Name = "c1", DataType = "int", NotNull = true, CommonType = new DbTypeInt(), }); t1.Columns.Add(new ColumnInfo(t1) { Name = "c2", DataType = "int", NotNull = true, CommonType = new DbTypeInt(), }); var ix = new IndexInfo(t1); ix.Columns.Add(new ColumnReference { RefColumn = t1.Columns[0] }); ix.ConstraintName = "ix1"; t1.Indexes.Add(ix); var pk = new PrimaryKeyInfo(t1); pk.Columns.Add(new ColumnReference {RefColumn = t1.Columns[0]}); pk.ConstraintName = "pk_t1"; t1.PrimaryKey = pk; db1.Tables.Add(t1); var v1 = new ViewInfo(db1) { Name = "v1", Schema = "dbo", CreateSql = "create view v1 as select * from t1", }; db1.Views.Add(v1); var db2 = db1.CloneDatabase(); mangle(db2); var plan = new AlterPlan(db1); DbDiffTool.AlterDatabase(plan, db1, db2, new DbDiffOptions()); var caps = SqlServerDatabaseFactory.Instance.DumperCaps; plan.AddLogicalDependencies(caps, new DbDiffOptions()); plan.Transform(caps, new DbDiffOptions()); var runner = plan.CreateRunner(); var sw = new StringWriter(); var sqlo = new SqlOutputStream(SqlServerDatabaseFactory.Instance.CreateDialect(), sw, new SqlFormatProperties()); var dmp = SqlServerDatabaseFactory.Instance.CreateDumper(sqlo, new SqlFormatProperties()); runner.Run(dmp, new DbDiffOptions()); string sql = sw.ToString(); Assert.IsNotNull(sql); //string expectedTran = TransformSql(expectedResult); //string sqlTran = TransformSql(sql); //for(int i = 0; i < expectedResult.Length; i++) //{ // Assert.AreEqual(expectedTran[i], sqlTran[i]); //} Assert.AreEqual(TransformSql(expectedResult), TransformSql(sql)); }
public static DbObjectPairing CreateTablePairing(TableInfo oldTable, TableInfo newTable) { var src = new DatabaseInfo(); var dst = src.CloneDatabase(); src.AddObject(oldTable, true); dst.AddObject(newTable, true); DbObjectPairing pairing = new DbObjectPairing(src, dst); return pairing; }
public AlterPlanBase(DatabaseInfo db) { Structure = db.CloneDatabase(); }