add_column :students, :student_id, :integer
Student.all.each { |s| s.update_attributes!(:student_id => s.id+10000) }I run this locally.
rake db:migrateIt worked without any problem.
Then I deployed to Heroku and run;
heroku rake db:migrateI found this error.
uninitialized constant AddStudentIdToStudents::StudentAfter googling for a while, I found this blog post Heroku Migration Fails to Update Attributes: reset_column_information
The way to solve this issue(don't know why) is to open up the class inside migration file like this;
This works for me.class AddStudentIdToStudents < ActiveRecord::Migrationclass Student < ActiveRecord::Base; enddef changeadd_column :students, :student_id, :integerStudent.all.each { |s| s.update_attributes!(:student_id => s.id+10000) }endend
Note: Rails 3.1.0
No comments:
Post a Comment