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 VdbLastVersionConnection(VersionDb vdb) : base(new VdbLastVersionConnectionFactory { FileName = vdb.FileName }) { m_vdb = vdb; }
public VdbVariantNode(ITreeNode parent, IFileHandler fhandler) : base(parent, fhandler) { if (parent is VdbVariantsNode) { m_db = ((VdbVariantsNode)parent).m_db; } }
public VersionDb GetVdb() { if (m_vdb == null && !String.IsNullOrEmpty(VdbFile)) { m_vdb = new VersionDb(VdbFile); } return(m_vdb); }
public VdbTreeNode(ITreeNode parent, IFileHandler fhandler) : base(parent, fhandler) { m_db = new VersionDb(fhandler.FileObject.DataDiskPath); SetAppObject(new VersionDbAppObject { VdbFile = fhandler.FileObject.DataDiskPath }); }
public VersionDef GetVersion() { if (m_version == null) { var vdb = new VersionDb(Path.Combine(Core.DataDirectory, VdbFile)); m_version = new VersionDef(vdb, Version); } return(m_version); }
public VdbVariantVersionDef GetVersion() { if (m_version == null) { var vdb = new VersionDb(VdbFile); var ver = new VersionDef(vdb, Version); m_version = new VdbVariantVersionDef(ver, new DiskFile(Path.Combine(vdb.VariantsDirectory, Variant))); } return(m_version); }
public override bool SuitableFor(AppObject appobj) { var ao = appobj as VersionDbAppObject; if (ao != null) { m_vdb = ao.GetVdb(); return(true); } return(false); }
public override bool CreateFile(string fn) { VersionDbProperties props = new VersionDbProperties(); props.Dialect = GenericDialect.Instance; VersionDb vdb = new VersionDb(props); vdb.m_file = fn; if (VersionDbPropsForm.Run(vdb)) { vdb.Save(); return(true); } return(false); }
public override void RunCommand() { if (!LicenseTool.FeatureAllowedMsg(VersionedDbFeature.Test)) { Logging.Error("Database Versioning edition required"); return; } var vdb = new VersionDb(Vdb); var api = new jsdm.Api(); var create = new jsdm.CreateModelProps(); api.Url = String.Format("{0}?login={1}&password={2}", Url, Login, Password); create.Name = Model; create.Dialect = vdb.Dialect.DialectName; create.Versioned = true; string model = api.CreateModel(create); for (int i = 0; i < vdb.Versions.Count; i++) { var ver = vdb.Versions[i]; using (var sr = new StreamReader(ver.GetFile())) { Logging.Info("Uploading version " + ver.Name); string content = sr.ReadToEnd(); if (i > 0) { api.AddModelVersion(model, new Plugin.versiondb.jsdm.CreateVersionProps { Name = ver.Name, Ordinal = i + 1 }); } api.ImportDbStructure(model, i + 1, content, true); } } Logging.Info("Created mode with key " + model); }
public VersionDbPropsForm(VersionDb db) { InitializeComponent(); m_w0 = Width; m_h0 = Height; m_db = db; if (db.Versions.Count == 0) { if (String.IsNullOrEmpty(m_db.m_props.GetVersionSql) && String.IsNullOrEmpty(m_db.m_props.SetVersionSql)) { chbCreateDefaultVariables.Checked = true; } chbCreateDefaultVariables_CheckedChanged(this, EventArgs.Empty); } else { chbCreateDefaultVariables.Visible = false; } foreach (var item in DialectAddonType.GetAllDialects(true)) { cbxDialect.Items.Add(item); } cbxDialect.SelectedIndex = 0; foreach (object item in cbxDialect.Items) { if (item is ISqlDialect && ((ISqlDialect)item).DisplayName == db.m_props.Dialect.DisplayName) { cbxDialect.SelectedItem = item; } } chbForceSingleSchema.Checked = m_db.m_props.ForceSingleSchema; codeEditorGet.SetCodeText(m_db.m_props.GetVersionSql, false); codeEditorSet.SetCodeText(m_db.m_props.SetVersionSql, false); }
public static bool Run(VersionDb db) { var win = new VersionDbPropsForm(db); if (win.ShowDialogEx() == DialogResult.OK) { db.m_props.ForceSingleSchema = win.chbForceSingleSchema.Checked; db.m_props.Dialect = (ISqlDialect)win.cbxDialect.SelectedItem; if (win.chbCreateDefaultVariables.Checked) { db.CreateDefaultVariableTable(); } else { db.m_props.GetVersionSql = win.codeEditorGet.CodeText; db.m_props.SetVersionSql = win.codeEditorSet.CodeText; } return(true); } return(false); }
public VersionDef(VersionDb db, XmlElement xml) { Db = db; Load(xml); }
public DbCreatorGeneratorCommand(VersionDb vdb) { m_versionDb = vdb; NamespaceName = "Generated"; ClassName = "DbCreator"; }
public VdbVersionsNode(ITreeNode parent, VersionDb db) : base(parent, "versions") { m_db = db; }
public VdbVariantVersionsNode(ITreeNode parent, VersionDb db, IVirtualFile varfile) : base(parent, "versions") { m_db = db; m_varfile = varfile; }
public VersionDbAppObject(VersionDb vdb) { m_vdb = vdb; VdbFile = m_vdb.FileName; }
public VdbVariantsNode(ITreeNode parent, VersionDb db) : base(parent, new DiskFolder(db.VariantsDirectory), "variants") { m_db = db; }
public VersionDef(VersionDb db, string name) { Db = db; Name = name; GroupId = Guid.NewGuid().ToString(); }