Nick Berveiler
2008-Jan-08 01:21 UTC
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2008-Jan-08 01:31 UTC
Re: ignoring :limit on string field migrations for postgresql
Try specifying :default => nil On Jan 8, 2008 11:51 AM, Nick Berveiler <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nick Berveiler
2008-Jan-08 01:45 UTC
Re: ignoring :limit on string field migrations for postgresq
: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 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. Nick Ryan Bigg wrote:> Try specifying :default => nil >-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Marable
2008-Jan-16 20:51 UTC
Re: ignoring :limit on string field migrations for postgresq
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> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---