Welcome to mirror list, hosted at ThFree Co, Russian Federation.

postgresql_limit_fix.rb « initializers « config - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4224d857e8abeda5dad2e4b88fb78d5336051da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
  class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
    module LimitFilter
      def add_column(table_name, column_name, type, options = {})
        options.delete(:limit) if type == :text
        super(table_name, column_name, type, options)
      end

      def change_column(table_name, column_name, type, options = {})
        options.delete(:limit) if type == :text
        super(table_name, column_name, type, options)
      end
    end

    prepend ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::LimitFilter

    class TableDefinition
      def text(*args)
        options = args.extract_options!
        options.delete(:limit)
        column_names = args
        type = :text
        column_names.each { |name| column(name, type, options) }
      end
    end
  end
end