Sha256: 8444c72c91f9dfe94299ab579cebb4edbe5cd7b5867e74dc22bb7b8df86948e5

Contents?: true

Size: 838 Bytes

Versions: 4

Compression:

Stored size: 838 Bytes

Contents

require 'delegate'

module ActiveRecord
  # = Active Record Schema Dumper
  #
  # This class is used to dump the database schema for some connection to some
  # output format (i.e., ActiveRecord::Schema).
  class SchemaDumper

    private
    class TableSorter < SimpleDelegator
      def columns(table)
        __getobj__.columns(table).sort_by(&:name)
      end

      def indexes(table)
        __getobj__.indexes(table).sort_by(&:name)
      end

      def foreign_keys(table)
        __getobj__.indexes(table).sort_by(&:name)
      end
    end

    def table_with_sorting(table, stream)
      old_connection = @connection
      @connection = TableSorter.new(old_connection)
      result = table_without_sorting(table, stream)
      @connection = old_connection
      result
    end
    alias_method_chain :table, :sorting

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fix-db-schema-conflicts-1.2.0 lib/fix_db_schema_conflicts/schema_dumper.rb
fix-db-schema-conflicts-1.1.0 lib/fix_db_schema_conflicts/schema_dumper.rb
fix-db-schema-conflicts-1.0.2 lib/fix_db_schema_conflicts/schema_dumper.rb
fix-db-schema-conflicts-1.0.1 lib/fix_db_schema_conflicts/schema_dumper.rb