示例#1
0
        public virtual void WriteStructureBeforeData(IDatabaseStructure db)
        {
            // create tables without foreign keys
            DatabaseStructure dbcopy = new DatabaseStructure(db);

            foreach (TableStructure tbl in dbcopy.Tables)
            {
                tbl.RemoveConstraints <IForeignKey>();
            }
            m_dmp.CreateDatabaseObjects(dbcopy, new CreateDatabaseObjectsProps
            {
                CreateSpecificObjects = false
            });
        }
示例#2
0
        public void CreateAllObjects(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect)
        {
            var dbmem = new DatabaseStructureMembers
            {
                TableList             = true,
                TableMembers          = TableStructureMembers.AllNoRefs,
                DomainList            = true,
                DomainDetails         = true,
                SpecificObjectList    = true,
                SpecificObjectDetails = true,
                LoadDependencies      = true,
                IgnoreSystemObjects   = true,
            };
            var dbs   = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null));
            var props = new CreateDatabaseObjectsProps
            {
                CreateDomains         = Domains,
                CreateFixedData       = FixedData,
                CreateSchemata        = Schemata,
                CreateSpecificObjects = SpecificObjects,
                CreateTables          = Tables
            };
            IMigrationProfile profile = dialect.CreateMigrationProfile();

            dialect.MigrateDatabase(dbs, profile, null);

            dmp.CreateDatabaseObjects(dbs, props);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
 public void CreateSpecificObjects(ISqlDumper dmp, IDatabaseStructure db)
 {
     dmp.CreateDatabaseObjects(db, new CreateDatabaseObjectsProps
     {
         AllFlags = false,
         CreateSpecificObjects = true,
     });
 }
示例#6
0
        public void CreateTables(ISqlDumper dmp, IDatabaseStructure db)
        {
            // create tables without foreign keys
            DatabaseStructure dbcopy = new DatabaseStructure(db);

            foreach (TableStructure tbl in dbcopy.Tables)
            {
                RemoveUnwantedTableFeature(tbl);
            }
            dmp.CreateDatabaseObjects(dbcopy, new CreateDatabaseObjectsProps
            {
                AllFlags     = false,
                CreateTables = true,
            });
        }
示例#7
0
        public override void GenerateSql(AppObject appobj, ISqlDumper dmp, ISqlDialect dialect)
        {
            var vdb = (VersionDbAppObject)appobj;

            var fromv = vdb.GetVdb().FindVersion(FromVersion);
            var tov   = vdb.GetVdb().FindVersion(ToVersion);

            DatabaseStructure fromstruct = null;

            if (fromv != null)
            {
                fromstruct = DatabaseStructure.Load(fromv.GetFile());
            }
            DatabaseStructure tostruct = null;

            if (tov != null)
            {
                tostruct = DatabaseStructure.Load(tov.GetFile());
            }
            if (tostruct == null)
            {
                return;
            }

            DbDiffOptions opts = new DbDiffOptions();

            //if (prev != null) dmp.TargetDb = new DbDefSource(DatabaseStructure.Load(prev.GetFile()), DbDefSource.ReadOnly.Flag);
            opts.AllowRecreateTable = true;
            if (fromstruct == null)
            {
                dmp.CreateDatabaseObjects(tostruct);
            }
            else
            {
                dmp.AlterDatabase(fromstruct, tostruct, opts, new Plugin.dbmodel.DbDefSource(fromstruct, Plugin.dbmodel.DbDefSource.ReadOnly.Flag), null);
            }

            tov.SetVersionSql(dmp);
        }
示例#8
0
 public static void CreateDatabaseObjects(this ISqlDumper dmp, IDatabaseStructure db)
 {
     dmp.CreateDatabaseObjects(db, new CreateDatabaseObjectsProps());
 }