public override void MergeSchema() { SchemaMerge sm = new SchemaMerge(this.GetType()); using (SqlConnection cn = GetConnection() as SqlConnection) { cn.Open(); sm.Execute(cn); } }
public void CreateNewTables() { var sm = new SchemaMerge <PostulateDb>(); using (IDbConnection cn = sm.GetConnection()) { cn.Open(); sm.Execute(cn); Assert.IsTrue(AllTablesExist(cn, "TableA", "TableB", "TableC")); } }
public void DetectNewTables() { var sm = new SchemaMerge <PostulateDb>(); var diffs = sm.Compare(); Assert.IsTrue( diffs.Any(item1 => item1.ActionType == MergeActionType.Create && item1.ObjectType == MergeObjectType.Table && item1.Description.Contains("TableA") && diffs.Any(item2 => item2.ActionType == MergeActionType.Create && item2.ObjectType == MergeObjectType.Table && item2.Description.Contains("TableB")))); }
static void Main() { var sm = new SchemaMerge <TdgDb>(); sm.CreateIfNotExists((cn, db) => { var orgs = new OrgSeedData(); orgs.Generate(cn, db); var states = new StateSeedData(); states.Generate(cn, db); }); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
public void CreateNewKeyColumnsInNonEmptyTable() { var sm = new SchemaMerge <PostulateDb>(); using (IDbConnection cn = sm.GetConnection()) { cn.Open(); // create tables A, B, and C sm.Execute(cn); var record = new TableA() { FirstName = "Adam", LastName = "O'Neil" }; new PostulateDb().Save(record); } }
public void CreateNewKeyColumnsInEmptyTable() { var sm = new SchemaMerge <PostulateDb>(); using (IDbConnection cn = sm.GetConnection()) { cn.Open(); // create tables A, B, and C sm.Execute(cn); // drop PK on table A cn.Execute("ALTER TABLE [dbo].[TableA] DROP CONSTRAINT [PK_TableA]"); cn.Execute("ALTER TABLE [dbo].[TableA] DROP COLUMN [LastName]"); // restore them along with primary key sm.Execute(cn); Assert.IsTrue(PKColumnsEqual(cn, "TableA", "FirstName", "LastName")); } }
public void CreateNewNonKeyColumns() { var sm = new SchemaMerge <PostulateDb>(); using (IDbConnection cn = sm.GetConnection()) { cn.Open(); // create tables A, B, and C sm.Execute(cn); // drop a few columns cn.Execute("ALTER TABLE [dbo].[TableC] DROP COLUMN [SomeDate]"); cn.Execute("ALTER TABLE [dbo].[TableC] DROP COLUMN [SomeDouble]"); // add them back sm.Execute(cn); Assert.IsTrue(AllColumnsExist(cn, "TableC", "SomeDate", "SomeDouble")); } }
public void CreateIfNotExists() { var sm = new SchemaMerge <Models.Tdg.CreateIfNotExistsDb>(); sm.CreateIfNotExists(); }