# Datatypes (Mysql) in Rails Migrations

**URL:** <https://www.ruby-forum.com/t/datatypes-mysql-in-rails-migrations/106478>\
**Category:** Rails\
**Created:** [June 11, 2007, 3:52am UTC](https://www.ruby-forum.com/t/datatypes-mysql-in-rails-migrations/106478 "2007-06-11T03:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 11, 2007, 3:52am UTC](https://www.ruby-forum.com/t/datatypes-mysql-in-rails-migrations/106478/1 "2007-06-11T03:52:05Z")

</div>

Hi

I’m using integer for most of my numeric data, and this is fine, but the  
system I am building will convert my data structures OLTP to OLAP for  
reporting. This will require TONS of data to be saved. In an effort to  
reduce wasted space I’d rather use tinyint/smallint and other such more  
precise data types in mysql.

Couldn’t find any documentation about these ‘nonstandard’ data types. In  
addition I couldn’t find anything on use column options like “unsigned”.

Thanks.

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 11, 2007, 4:45am UTC](https://www.ruby-forum.com/t/datatypes-mysql-in-rails-migrations/106478/2 "2007-06-11T04:45:42Z")

</div>

On 6/10/07, Jean N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m using integer for most of my numeric data, and this is fine, but the  
> system I am building will convert my data structures OLTP to OLAP for  
> reporting. This will require TONS of data to be saved. In an effort to  
> reduce wasted space I’d rather use tinyint/smallint and other such more  
> precise data types in mysql.
> 
> Couldn’t find any documentation about these ‘nonstandard’ data types. In  
> addition I couldn’t find anything on use column options like “unsigned”.

Pass a string as the column type and it’ll be interpreted as a literal  
sql fragment:  
t.column :foo, ‘tinyint(2) unsigned’

Be sure not to use tinyint(1) since it’s used for booleans only.

jeremy

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [June 11, 2007, 4:07pm UTC](https://www.ruby-forum.com/t/datatypes-mysql-in-rails-migrations/106478/3 "2007-06-11T16:07:11Z")

</div>

Jeremy K. wrote:

> Pass a string as the column type and it’ll be interpreted as a literal  
> sql fragment:  
> t.column :foo, ‘tinyint(2) unsigned’
> 
> Be sure not to use tinyint(1) since it’s used for booleans only.
> 
> jeremy

Thanks! Where did you find out about this anyway?
