def init_sources()
        return unless defined? Rho::RhoConfig::sources

        @all_models_loaded = true

        uniq_sources = Rho::RhoConfig::sources.values
        puts 'init_sources: ' #+ uniq_sources.inspect

        uniq_sources.each do |source|
            source['str_associations'] = ""
        end

        uniq_sources.each do |source|
          partition = source['partition']
          @db_partitions[partition] = nil unless @db_partitions[partition]

          if source['belongs_to']
            source['belongs_to'].each do |hash_pair|
                attrib = hash_pair.keys[0]
                src_name = hash_pair.values[0]

                associationsSrc = find_src_byname(uniq_sources, src_name)
                if !associationsSrc
                    puts "Error: belongs_to '#{source['name']}' : source name '#{src_name}' does not exist."
                    next
                end

                str_associations = associationsSrc['str_associations']
                str_associations = "" unless str_associations
                str_associations += ',' if str_associations.length() > 0

                str_associations += source['name'] + ',' + attrib
                associationsSrc['str_associations'] = str_associations
            end
          end
        end

        #user partition should alwayse exist
        @db_partitions['user'] = nil unless @db_partitions['user']
        hash_migrate = {}
        puts "@db_partitions : #{@db_partitions}"
        @db_partitions.each do |partition, db|
            db = Rhom::RhomDbAdapter.new(Rho::RhoFSConnector::get_db_fullpathname(partition), partition) unless db
            db.start_transaction
            begin
                init_db_sources(db, uniq_sources, partition,hash_migrate)
                #SyncEngine.update_blob_attribs(partition, -1 )

                db.commit
            rescue Exception => e
                trace_msg = e.backtrace.join("\n")
                puts "exception when init_db_sources: #{e}; Trace:" + trace_msg

                db.rollback
            end

            @db_partitions[partition] = db
        end

        puts "Migrate schema sources: #{hash_migrate}"
        ::Rho::RHO.init_schema_sources(hash_migrate)
        ::Rho::RHO.check_sources_migration(uniq_sources)

        #@db_partitions.each do |partition, db|
        #    SyncEngine.update_blob_attribs(partition, -1 )
        #end

        ::Rho::RHO.init_sync_source_properties(uniq_sources)
    end
def init_sources()
        return unless defined? Rho::RhoConfig::sources

        @all_models_loaded = true

        uniq_sources = Rho::RhoConfig::sources.values
        puts 'init_sources: ' #+ uniq_sources.inspect

        uniq_sources.each do |source|
            source['str_associations'] = ""
        end

        uniq_sources.each do |source|
          partition = source['partition']
          @db_partitions[partition] = nil unless @db_partitions[partition]

          if source['belongs_to']
            source['belongs_to'].each do |hash_pair|
                attrib = hash_pair.keys[0]
                src_name = hash_pair.values[0]

                associationsSrc = find_src_byname(uniq_sources, src_name)
                if !associationsSrc
                    puts "Error: belongs_to '#{source['name']}' : source name '#{src_name}' does not exist."
                    next
                end

                str_associations = associationsSrc['str_associations']
                str_associations = "" unless str_associations
                str_associations += ',' if str_associations.length() > 0

                str_associations += source['name'] + ',' + attrib
                associationsSrc['str_associations'] = str_associations
            end
          end
        end

        #user partition should alwayse exist
        @db_partitions['user'] = nil unless @db_partitions['user']
        hash_migrate = {}
        puts "@db_partitions : #{@db_partitions}"
        @db_partitions.each do |partition, db|
            db = Rhom::RhomDbAdapter.new(Rho::RhoFSConnector::get_db_fullpathname(partition), partition) unless db
            db.start_transaction
            begin
                init_db_sources(db, uniq_sources, partition,hash_migrate)
                #SyncEngine.update_blob_attribs(partition, -1 )

                db.commit
            rescue Exception => e
                trace_msg = e.backtrace.join("\n")
                puts "exception when init_db_sources: #{e}; Trace:" + trace_msg

                db.rollback
            end

            @db_partitions[partition] = db
        end

        puts "Migrate schema sources: #{hash_migrate}"
        ::Rho::RHO.init_schema_sources(hash_migrate)
        ::Rho::RHO.check_sources_migration(uniq_sources)

        #@db_partitions.each do |partition, db|
        #    SyncEngine.update_blob_attribs(partition, -1 )
        #end

        ::Rho::RHO.init_sync_source_properties(uniq_sources)
    end
setup the sources table and model attributes for all applications