Rails migration to add boolean column to Postgres on Heroku

Posted by pmc255 on Stack Overflow See other posts from Stack Overflow or by pmc255
Published on 2010-06-06T09:34:16Z Indexed on 2010/06/06 9:42 UTC
Read the original article Hit count: 540

I'm trying to execute a simple Rails migration to add a boolean column to an existing table. Here's the add_column call:

add_column :users, :soliciting, :boolean, :null => false, :default => false

However, after the migration runs (successfully, with no errors), I don't see the new column. If I go into the console and list the columns on the User table, for example, with this command:

>> User.columns.each { |c| puts "#{c.name} : #{c.type}" }

All the other columns show up, but not the one I just added with the migration. What's even more strange is that looking up a random user object yields the Postgres version of booleans (Ruby strings)

>> User.find(1).soliciting
=> "t"

However, the existing boolean columns all show up with standard Ruby boolean values of true and false.

What's going on here? Is the migration actually complete? Why doesn't the column show up, yet is accessible in the model objects?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about postgresql