Howdy Y''all, I was thrilled to recently discover migrations, as that framework addresses a common problem in an elegant way. I have, however, gotten tripped up a bit as I''ve worked with them. The first problem I encountered was that, though I was using a BigInt data type in a field in my dev database, my unit tests were failing because when I copied the schema from the dev to the testing DB, it was copied as a plain int. This caused the large values in my unit tests to fail. I understand why the Migration framework doesn''t support this, since not all database engines might support BigInts, but it did catch me by surprise. So, my next idea was to convert the field to text. While I only need 13 characters in this field, using the change_column command with a :string type resulted in a varchar with a length of 255. I tried adding a :size => 13 option (and a :length => 13 option), but it didn''t make any difference. So, my actual question: is there any way to specify the length of a field, or does one just take whatever the framework gives you by default? Thanks in advance for any info! Sean -- Posted via http://www.ruby-forum.com/.
Sean McMains wrote:> So, my next idea was to convert the field to text. While I only need 13 > characters in this field, using the change_column command with a :string > type resulted in a varchar with a length of 255. I tried adding a :size > => 13 option (and a :length => 13 option), but it didn''t make any > difference. So, my actual question: is there any way to specify the > length of a field, or does one just take whatever the framework gives > you by default?What you want is the somewhat unintuitive :limit => 13 Regards, Victor Grey -- Posted via http://www.ruby-forum.com/.
> What you want is the somewhat unintuitive :limit => 13 > > Regards, > Victor GreyYou''re absolutely right, Victor. Thank you! Sean -- Posted via http://www.ruby-forum.com/.
johann.petrak@gmail.com
2006-May-07 19:27 UTC
[Rails] Re: Migration, BigInts, and string lengths
Guest wrote:> Sean McMains wrote: >> So, my next idea was to convert the field to text. While I only need 13 >> characters in this field, using the change_column command with a :string >> type resulted in a varchar with a length of 255. I tried adding a :size >> => 13 option (and a :length => 13 option), but it didn''t make any >> difference. So, my actual question: is there any way to specify the >> length of a field, or does one just take whatever the framework gives >> you by default? > > What you want is the somewhat unintuitive :limit => 13 >I was looking for this too and I am glad I found this reply. However -- where in the documentation can I find this information. Or information about what other things are possible in the options field? -- Posted via http://www.ruby-forum.com/.
johann.petrak@gmail.com wrote:> Guest wrote: >> Sean McMains wrote: >>> So, my next idea was to convert the field to text. While I only need 13 >>> characters in this field, using the change_column command with a :string >>> type resulted in a varchar with a length of 255. I tried adding a :size >>> => 13 option (and a :length => 13 option), but it didn''t make any >>> difference. So, my actual question: is there any way to specify the >>> length of a field, or does one just take whatever the framework gives >>> you by default? >> What you want is the somewhat unintuitive :limit => 13 >> > > I was looking for this too and I am glad I found this reply. > > However -- where in the documentation can I find this information. Or > information about what other things are possible in the options field? >http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#M000659 -- Alex