[Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Adam Stegman
Sorry, I should have mentioned - the migration before it is one where that active column is added. The migration after alters a column in a different table. The column is definitely added before this migration runs. On Feb 11, 1:23 pm, Adam Stegman adam.steg...@gmail.com wrote: I have a

[Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Adam Stegman
I tried doing the whole thing in one migration - adding the column and setting the value, and I got the exact same behavior with this migration: class AddActiveToItems ActiveRecord::Migration def self.up add_column :items, :active, :boolean Item.all.each do |item| if

[Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Jarin Udom
You need to put Item.reset_column_information at the top of the migration so Rails reloads the altered table. Jarin Udom Robot Mode LLC http://robotmo.de On Feb 11, 12:58 pm, Adam Stegman adam.steg...@gmail.com wrote: I tried doing the whole thing in one migration - adding the column and

[Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Jarin Udom
Oh also Item.reset_column_information needs to be after the add_column and before the Item.all.each if you are adding the column and manipulating the data in the same migration. If it is 2 separate migrations, just put it at the top of the 2nd one. Jarin Udom Robot Mode LLC http://robotmo.de On

Re: [Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Adam
Sure enough, I see that exact information in the Migration documentation. http://api.rubyonrails.org/classes/ActiveRecord/Migration.html It works great now. Thank you. Adam On Thu, Feb 11, 2010 at 3:33 PM, Jarin Udom ja...@robotmo.de wrote: Oh also Item.reset_column_information needs to be

[Rails] Re: Migration commits when run by itself (db:migrate:up), but not with other migrations (db:migrate)

2010-02-11 Thread Frederick Cheung
On Feb 11, 9:42 pm, Adam adam.steg...@gmail.com wrote: Sure enough, I see that exact information in the Migration documentation.http://api.rubyonrails.org/classes/ActiveRecord/Migration.html It works great now. Thank you. You should also be careful about using model classes in migrations -