debian-mirror-gitlab/config/initializers/postgresql_limit_fix.rb

28 lines
856 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
2016-11-03 12:29:30 +05:30
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
2014-09-02 18:07:02 +05:30
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