Beispiel #1
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 #2
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);
        }