public void GetAlterSql(ISqlDumper dmp) { DumpSubFolder(dmp, "before"); VersionDef current = this; VersionDef prev = current.GetVersion(-1); VersionDb vdb = current.Db; DatabaseStructure curstruct = DatabaseStructure.Load(current.GetFile()); DatabaseStructure prevstruct = null; if (prev != null) { prevstruct = DatabaseStructure.Load(prev.GetFile()); } ISqlDialect dialect = vdb.Dialect; DbDiffOptions opts = new DbDiffOptions(); //if (prev != null) dmp.TargetDb = new DbDefSource(DatabaseStructure.Load(prev.GetFile()), DbDefSource.ReadOnly.Flag); opts.AllowRecreateTable = true; if (prevstruct == null) { dmp.CreateDatabaseObjects(curstruct); } else { dmp.AlterDatabase(prevstruct, curstruct, opts, new Plugin.dbmodel.DbDefSource(prevstruct, Plugin.dbmodel.DbDefSource.ReadOnly.Flag), AddSubFoldersToPlan); } DumpSubFolder(dmp, "after"); current.SetVersionSql(dmp); }
public DatabaseStructure LoadStructure() { var dbs = DatabaseStructure.Load(Version.GetFile()); var mod = new VariantDef(VariantFile); mod.RunTransform(dbs); return(dbs); }
public static DatabaseStructure LoadStructure(this VersionDef verdef, VariantDef vardef) { if (verdef == null) { return(null); } var model = DatabaseStructure.Load(verdef.GetFile()); vardef.RunTransform(model); return(model); }
public override ITreeNode[] GetChildren() { return(new ITreeNode[] { new VdbDbDefTreeNode(this, new VersionDbFileHandler { FileObject = new DiskFile(m_version.GetFile()) }), new VdbScriptsTreeNode(this, m_version, "before", "s_scripts_before_change"), new VdbScriptsTreeNode(this, m_version, "before-nofk", "s_scripts_before_change_no_fk"), new VdbScriptsTreeNode(this, m_version, "after-nofk", "s_scripts_after_change_no_fk"), new VdbScriptsTreeNode(this, m_version, "after", "s_scripts_after_change"), }); }
public void AddVersion(string version) { Reload(); DatabaseStructure dbs; if (Versions.Count > 0) { dbs = DatabaseStructure.Load(Versions[Versions.Count - 1].GetFile()); } else { dbs = new DatabaseStructure(); } dbs.SetProps(m_props); var vd = new VersionDef(this, version); Versions.Add(vd); WantVersionsDirectory(); dbs.Save(vd.GetFile()); Save(); }