# Migration, BigInts, and string lengths

**URL:** <https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190>\
**Category:** Rails\
**Created:** [May 1, 2006, 1:51am UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190 "2006-05-01T01:51:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanmctex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@seanmctex](https://www.ruby-forum.com/u/seanmctex)\
**Post date:** [May 1, 2006, 1:51am UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190/1 "2006-05-01T01:51:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seanmctex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@seanmctex](https://www.ruby-forum.com/u/seanmctex)\
**Post date:** [May 1, 2006, 7:08am UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190/2 "2006-05-01T07:08:41Z")

</div>

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 G.

---

<div class="post-metadata">

**Author:** ![seanmctex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@seanmctex](https://www.ruby-forum.com/u/seanmctex)\
**Post date:** [May 2, 2006, 4:57am UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190/3 "2006-05-02T04:57:12Z")

</div>

> What you want is the somewhat unintuitive :limit =\> 13
> 
> Regards,  
> Victor G.

You’re absolutely right, Victor. Thank you!

Sean

---

<div class="post-metadata">

**Author:** ![seanmctex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@seanmctex](https://www.ruby-forum.com/u/seanmctex)\
**Post date:** [May 7, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190/4 "2006-05-07T21:27:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![seanmctex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@seanmctex](https://www.ruby-forum.com/u/seanmctex)\
**Post date:** [May 8, 2006, 9:58am UTC](https://www.ruby-forum.com/t/migration-bigints-and-string-lengths/59190/5 "2006-05-08T09:58:52Z")

</div>

removed\_email\_address@domain.invalid 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/ConnectionAdapters/TableDefinition.html#M000659](http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#M000659)
