My googlefu must be weak because I cannot find anything to tell me the default limit of a string column in my Rails app (hosted at Heroku, using PostgreSQL as the database).
Any help would be appreciated!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ActiveRecord uses
varchar(255)(orcharacter varying (255)to be pedantic) if you don’t specify a specific limit. You can always hop into PostgreSQL withpsqland say\d your_tableto get the table as PostgreSQL sees it.I don’t think the default is specified anywhere but it is right here in the source:
The closest thing to a specification is in the Migrations Guide:
But that’s not about PostgreSQL and not exactly a guarantee.
As an aside, if you’re using PostgreSQL, you should almost always go straight to
:textand pretend that:stringdoesn’t exist. PostgreSQL treats them the same internally except that it has to do a length check onvarchar. There’s a bit more discussion on this over here in another one of my answers: Changing a column type to longer strings in rails.