Example #1
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);
        }
Example #2
0
        public void GenerateDropAllTables(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect)
        {
            DatabaseStructureMembers dbmem = new DatabaseStructureMembers
            {
                TableList           = true,
                TableMembers        = TableStructureMembers.ForeignKeys,
                IgnoreSystemObjects = true,
            };
            var dbs = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null));
            IMigrationProfile profile = dialect.CreateMigrationProfile();

            dialect.MigrateDatabase(dbs, profile, null);
            foreach (ITableStructure tbl in dbs.Tables)
            {
                if (conn.Dialect.IsSystemTable(tbl.FullName))
                {
                    continue;
                }
                foreach (IForeignKey fk in tbl.GetConstraints <IForeignKey>())
                {
                    dmp.DropConstraint(fk);
                }
            }
            foreach (ITableStructure tbl in dbs.Tables)
            {
                if (conn.Dialect.IsSystemTable(tbl.FullName))
                {
                    continue;
                }
                dmp.DropTable(tbl, DropFlags.None);
            }
        }
Example #3
0
        public void GenerateFillTable(ITableSource table, ISqlDumper dmp, ISqlDialect dialect)
        {
            IMigrationProfile profile = dialect.CreateMigrationProfile();
            var tbl = new TableStructure(table.InvokeLoadStructure(TableStructureMembers.AllNoRefs));

            dialect.MigrateTable(tbl, profile, null);
            GenerateFillTable(tbl, dmp);
        }
Example #4
0
        public override void GenerateSql(IDatabaseSource db, FullDatabaseRelatedName objname, ISqlDumper dmp, ISqlDialect dialect)
        {
            IMigrationProfile profile = dialect.CreateMigrationProfile();
            var tbl = new TableStructure(db.GetTable(objname.ObjectName).InvokeLoadStructure(TableStructureMembers.AllNoRefs));

            dialect.MigrateTable(tbl, profile, null);
            InsertTemplate(tbl, dmp, dialect);
        }
Example #5
0
 public static IMigrationProfile GetDefaultMigrationProfile(this ISqlDialect dialect)
 {
     lock (m_migrationProfileCache)
     {
         var res = m_migrationProfileCache.Get(dialect.DialectName, null);
         if (res == null)
         {
             res = dialect.CreateMigrationProfile();
             m_migrationProfileCache[dialect.DialectName] = res;
         }
         return(res);
     }
 }
Example #6
0
        public void CreateReferences(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect)
        {
            var dbmem = new DatabaseStructureMembers
            {
                TableList           = true,
                TableMembers        = TableStructureMembers.AllNoRefs,
                IgnoreSystemObjects = true,
            };
            var dbs = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null));
            IMigrationProfile profile = dialect.CreateMigrationProfile();

            dialect.MigrateDatabase(dbs, profile, null);
            CreateReferences(dmp, dbs);
        }
Example #7
0
        public void CreateDomains(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect)
        {
            var dbmem = new DatabaseStructureMembers
            {
                DomainDetails       = true,
                DomainList          = true,
                IgnoreSystemObjects = true,
            };
            var dbs = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null));
            IMigrationProfile profile = dialect.CreateMigrationProfile();

            dialect.MigrateDatabase(dbs, profile, null);

            CreateDomains(dmp, dbs);
        }
Example #8
0
        public void FillAllTables(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect)
        {
            var dbmem = new DatabaseStructureMembers
            {
                TableList    = true,
                TableMembers = TableStructureMembers.Columns,
            };
            var dbs = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null));
            IMigrationProfile profile = dialect.CreateMigrationProfile();

            dialect.MigrateDatabase(dbs, profile, null);
            foreach (var tbl in dbs.Tables)
            {
                GenerateFillTable(tbl, dmp);
            }
        }
Example #9
0
 public virtual IMigrationProfile CreateMigrationProfile()
 {
     return(m_dialect.CreateMigrationProfile());
 }