Forum: Ruby on Rails Migration, BigInts, and string lengths

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
096a09594a8de0ef479f0365864536fd?d=identicon&s=25 Sean Mcmains (seanmctex)
on 2006-05-01 01:51
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
2c17b1c9b894c3fcdccec587f1b6ee31?d=identicon&s=25 Guest (Guest)
on 2006-05-01 07:08
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
096a09594a8de0ef479f0365864536fd?d=identicon&s=25 Sean Mcmains (seanmctex)
on 2006-05-02 04:57
> What you want is the somewhat unintuitive :limit => 13
>
> Regards,
> Victor Grey

You're absolutely right, Victor. Thank you!

Sean
5ec3165c195346139bc787edd85361e8?d=identicon&s=25 Guest (Guest)
on 2006-05-07 21:27
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?
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-05-08 09:58
(Received via mailing list)
johann.petrak@gmail.com wrote:
>>
>
> 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/Co...
This topic is locked and can not be replied to.