Ejemplo n.º 1
0
        public void AlterDatabase()
        {
            var dbconn = this.FindDatabaseConnection(ConnPack);

            if (!AlterDatabaseVisible() || dbconn == null)
            {
                return;
            }
            var dbmem = new DatabaseStructureMembers();

            dbmem.DatabaseOptions = true;
            var m_db  = dbconn.InvokeLoadStructure(dbmem, null);
            var props = new DatabaseProperties
            {
                Name         = dbconn.DatabaseName,
                SpecificData = m_db.SpecificData,
            };

            if (DatabasePropertiesForm.Run(props, dbconn, true))
            {
                var plan = new AlterPlan();
                var opts = new DbDiffOptions();
                plan.ChangeDatabaseOptions(dbconn.DatabaseName, props.SpecificData);
                plan.Transform(dbconn.Dialect.DumperCaps, opts, dbconn);

                string alterSql = dbconn.Dialect.GenerateScript(dmp => plan.CreateRunner().Run(dmp, opts));
                if (SqlConfirmForm.Run(alterSql))
                {
                    dbconn.AlterDatabase(plan, opts);
                }
            }
        }
Ejemplo n.º 2
0
        /// 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);
        }
Ejemplo n.º 3
0
        public static void AlterDatabase(this IAlterProcessor proc, IDatabaseStructure src, IDatabaseStructure dst, DbDiffOptions opts, IDatabaseSource targetDb, Action <AlterPlan> extendPlan)
        {
            AlterPlan plan = new AlterPlan();

            DbDiffTool.AlterDatabase(plan, src, dst, opts);
            if (extendPlan != null)
            {
                extendPlan(plan);
            }
            plan.Transform(proc.AlterCaps, opts, targetDb);
            var run = plan.CreateRunner();

            run.Run(proc, opts);
        }
Ejemplo n.º 4
0
 public void AlterDatabase(AlterPlan plan, DbDiffOptions opts)
 {
     this.InvokeScript(dmp => plan.CreateRunner().Run(dmp, opts), null, plan.DenyTransaction);
 }