2012-10-09 19:41:14 -04:00
|
|
|
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
|
|
|
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
2016-09-21 08:46:13 -04:00
|
|
|
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
|
|
|
|
|
2012-10-09 19:41:14 -04:00
|
|
|
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
|