Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void GetAlterSql(ISqlDumper dmp)
        {
            VersionDef current = Version;
            VersionDef prev    = Version.GetVersion(-1);

            var vardef = new VariantDef(VariantFile);
            DatabaseStructure curstruct  = current.LoadStructure(vardef);
            DatabaseStructure prevstruct = prev.LoadStructure(vardef);
            ISqlDialect       dialect    = curstruct.Dialect ?? Version.Db.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), null);
            }

            current.SetVersionSql(dmp);
        }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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();
        }
Beispiel #7
0
 public VdbScriptsTreeNode(VdbVersionNode parent, VersionDef version, string scriptsSubDir, string title)
     : base(parent, new DiskFolder(version.GetPrivateSubFolder(scriptsSubDir)), "scripts")
 {
     m_title   = title;
     m_version = version;
 }
Beispiel #8
0
 public VdbVersionNode(ITreeNode parent, VersionDef version)
     : base(parent, version.Name)
 {
     m_version = version;
     SetAppObject(new VersionAppObject(m_version));
 }
Beispiel #9
0
 public VdbVariantVersionDef(VersionDef version, IVirtualFile varfile)
 {
     Version     = version;
     VariantFile = varfile;
 }
Beispiel #10
0
 public VersionAppObject(VersionDef version)
 {
     m_version = version;
     VdbFile   = IOTool.RelativePathTo(Core.DataDirectory, m_version.Db.FileName);
     Version   = m_version.Name;
 }
Beispiel #11
0
 public void DeleteVersion(VersionDef version)
 {
     Reload();
     Versions.Remove(version);
     Save();
 }