# MySQL migration: trying to create "not null" boolean column (RoR 2.0)

**URL:** <https://www.ruby-forum.com/t/mysql-migration-trying-to-create-not-null-boolean-column-ror-2-0/126846>\
**Category:** Rails\
**Created:** [January 22, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/mysql-migration-trying-to-create-not-null-boolean-column-ror-2-0/126846 "2008-01-22T18:44:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iledela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9d8465/32.png) [@iledela](https://www.ruby-forum.com/u/iledela)\
**Post date:** [January 22, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/mysql-migration-trying-to-create-not-null-boolean-column-ror-2-0/126846/1 "2008-01-22T18:44:31Z")

</div>

Hello everyone!

Disclaimer: I am really, really new to Rails and this is probably a  
really stupid question, but I have spent SO LONG trying to find an  
answer and I’ve gotten nowhere. Thanks in advance for indulging me!

I’m trying to set up a boolean column in my database through db/  
migrate/001\_create\_(whatever).rb. Here’s the relevant line:

t.boolean :type

When I use db:create:all to create the MySQL databases, it makes all  
columns null, which is a problem for this column. I tried:

t.boolean :type, :null =\> false

but that didn’t work and I’m wondering if there’s a different way of  
doing this in 2.0. Again, really sorry for the simple question but I  
feel like I’ve looked everywhere! Help much appreciated!

---

<div class="post-metadata">

**Author:** ![iledela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9d8465/32.png) [@iledela](https://www.ruby-forum.com/u/iledela)\
**Post date:** [January 22, 2008, 8:56pm UTC](https://www.ruby-forum.com/t/mysql-migration-trying-to-create-not-null-boolean-column-ror-2-0/126846/2 "2008-01-22T20:56:46Z")

</div>

db:create:all, should just create your databases (development, test  
and production). db:migrate should create your (whatever) table from  
your 001\_create\_(whatever).rb.

i am not sure if this is what you are wanting but try the “default”  
option… this way your column will always have a value…

t.boolean :type, :default =\> true, :null =\> false  
or  
t.boolean :type, :default =\> false, :null =\> false

let us know if this does not help…
