TheForeman foreman-rake db:migrate
task fails when upgrading between 1.3.x -> 1.4.x and from any version <=1.3 to at least 1.5.2. The fix is to edit the rake task /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb
. Bug #4518 is open for this issue.
The initial failure/error.
# foreman-rake db:migrate ... rake aborted! An error has occurred, all later migrations canceled: Mysql2::Error: Can't DROP 'inherited_from'; check that column/key exists: ALTER TABLE `user_roles` DROP `inherited_from` Tasks: TOP => db:migrate (See full trace by running task with --trace)
Comment out the offending #remove_column
method call in the migration rake task.
# vim /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb class RemoveUnusedRoleFields < ActiveRecord::Migration def up remove_column :users, :role_id #remove_column :user_roles, :inherited_from end def down add_column :users, :role_id, :integer add_column :user_roles, :inherited_from, :integer end end
Try again...
# foreman-rake db:migrate == RemoveUnusedRoleFields: migrating ========================================= -- remove_column(:users, :role_id) rake aborted! An error has occurred, all later migrations canceled: Mysql2::Error: Can't DROP 'role_id'; check that column/key exists: ALTER TABLE `users` DROP `role_id` Tasks: TOP => db:migrate (See full trace by running task with --trace)
Comment out the new offender.
# vim /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb class RemoveUnusedRoleFields < ActiveRecord::Migration def up #remove_column :users, :role_id #remove_column :user_roles, :inherited_from end def down add_column :users, :role_id, :integer add_column :user_roles, :inherited_from, :integer end end
Try yet again...
# foreman-rake db:migrate == RemoveUnusedRoleFields: migrating ========================================= == RemoveUnusedRoleFields: migrated (0.0000s) ================================ ... Recreating cache #
And the Migration should complete.