public override bool Save() { var dialect = m_conn.Dialect ?? GenericDialect.Instance; var plan = new AlterPlan(); var opts = new DbDiffOptions(); var log = new CachingLogger(LogLevel.Info); opts.AlterLogger = log; DbDiffTool.AlterDatabase(plan, new DbObjectPairing(m_origDb, m_db), opts); string alterSql = dialect.GenerateScript(dmp => plan.CreateRunner().Run(dmp, opts)); if (!SqlConfirmForm.Run(alterSql, dialect, log)) { return(false); } m_conn.AlterDatabase(plan, opts); objectGridView1.Modified = false; UpdateState(); LoadStructure(); return(true); }
private void CreateActions() { m_plan = new AlterPlan(); m_plan.Structure = m_dst; // optimalization ... plan fill not download extra data DbDiffTool.AlterDatabase(Plan, new DbObjectPairing(m_dst, m_src), m_options); DbDiffAction lastAlterTable = null; foreach (var op in m_plan.Operations) { DbDiffAction act; if (op.ParentTable != null) { // this operation should be added to ALTER TABLE operation if (lastAlterTable == null || lastAlterTable.ParentTable != op.ParentTable) { lastAlterTable = new DbDiffAction(this); lastAlterTable.ParentTable = op.ParentTable; lastAlterTable.AfterCreate(); m_actions.Elements.Add(lastAlterTable); } act = new DbDiffAction(this); act.Operation = op; act.IsChecked = true; act.AfterCreate(); lastAlterTable.Elements.Add(act); } else { act = new DbDiffAction(this); act.Operation = op; lastAlterTable = null; act.AfterCreate(); m_actions.Elements.Add(act); } } //this.AlterDatabase(m_dst, m_src, m_options); }