ignoring :limit on string field migrations for postgresql

By default, if a limit is not set on string fields in a migration, the
limit is set to 255. In postgresql, varchar fields can vary without
having a limit. Is it possible to write migrations that will keep the
varchar varying without a default limit set?

Thanks,
Nick

Try specifying :default => nil

:default => nil didn't work. I had already tried :limit => nil and that
didn't work either. I also tried :limit => nil, :default => nil. Still
no luck, the varchar length is still being set at 255. I may just have
to write all of my varchar fields as sql within the migration files
instead of using ruby code, but I am hoping to avoid that.

I might try to find the migration code and see if it is possible to add
fix, but I don't know if this wold be considered a bug or not and I
haven't gotten my feet wet in rails src code yet.

Nick

Ryan Bigg wrote:

Nick Berveiler wrote:

I might try to find the migration code and see if it is possible to add
a :limit => :ignore param or something like that and submit it as a bug
fix, but I don't know if this wold be considered a bug or not and I
haven't gotten my feet wet in rails src code yet.

I put this in an initializer:

<pre>
module ActiveRecord::ConnectionAdapters

  class PostgreSQLAdapter < AbstractAdapter

    # Monkey patched to remove varchar limit of 255 that Rails set,
since
    # it makes no performance difference in Postgres.
    def native_database_types #:nodoc:
      {
        :primary_key => "serial primary key",
        :string => { :name => "character varying" },
        :text => { :name => "text" },
        :integer => { :name => "integer" },
        :float => { :name => "float" },
        :decimal => { :name => "decimal" },
        :datetime => { :name => "timestamp" },
        :timestamp => { :name => "timestamp" },
        :time => { :name => "time" },
        :date => { :name => "date" },
        :binary => { :name => "bytea" },
        :boolean => { :name => "boolean" }
      }
    end

  end

end
</pre>