Ejemplo n.º 1
0
        public override void MergeSchema()
        {
            SchemaMerge sm = new SchemaMerge(this.GetType());

            using (SqlConnection cn = GetConnection() as SqlConnection)
            {
                cn.Open();
                sm.Execute(cn);
            }
        }
Ejemplo n.º 2
0
        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"));
            }
        }
Ejemplo n.º 3
0
        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"))));
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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"));
            }
        }
Ejemplo n.º 7
0
        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"));
            }
        }
Ejemplo n.º 8
0
        public void CreateIfNotExists()
        {
            var sm = new SchemaMerge <Models.Tdg.CreateIfNotExistsDb>();

            sm.CreateIfNotExists();
        }