Sha256: ed392eda521b84e5a313a2ce60f8bea3bfa1a1c11f4c78d5389e428f4dae37ec

Contents?: true

Size: 1003 Bytes

Versions: 3

Compression:

Stored size: 1003 Bytes

Contents

module ActiveRecord
  module PGCollation
    register :schema_dumper do
      require "active_record/connection_adapters/postgresql/schema_dumper"
      ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(SchemaDumper)
    end

    module SchemaDumper
      private

      def extensions(stream)
        super
        collations(stream)
      end

      def collations(stream)
        collations = @connection.collations

        if collations.any?
          stream.puts(%Q{  # These are collations that must be created before they can be used in the schema definition})
          collations.each do |collation|
            name = collation["name"]
            deterministic = collation["deterministic"]
            options = collation.except("name", "deterministic").map {|k,v| %Q{#{k}: "#{v}"}}.join(", ")
            stream.puts(%Q{  create_collation "#{name}", #{options}, deterministic: #{deterministic}})
          end
          stream.puts
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-pg_collation-0.1.2 lib/active_record/pg_collation/6.1/schema_dumper.rb
activerecord-pg_collation-0.1.1 lib/active_record/pg_collation/6.1/schema_dumper.rb
activerecord-pg_collation-0.1.0 lib/active_record/pg_collation/6.1/schema_dumper.rb