Bug #296
closedIncorrect family_id references breaks migration
Description
Upgrading to the latest 1.5 RC, and ran into this error when running db:migrate:
[root@jms foreman]# rake db:migrate --trace(in /usr/share/foreman)
- Invoke db:migrate (first_time)
- Invoke environment (first_time)
- Execute environment
- Execute db:migrate
CreateMediasOperatingsystemsAndMigrateData: migrating ===================
rake aborted!
An error has occurred, all later migrations canceled:
missing attribute: family_id
/usr/share/foreman/app/models/operatingsystem.rb:20:in `after_initialize'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/callbacks.rb:347:in `send'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/callbacks.rb:347:in `callback'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:1657:in `send'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:1657:in `instantiate_without_polymorphic_checks'
/usr/share/foreman/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/base.rb:52:in `instantiate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:661:in `find_by_sql'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:661:in `collect!'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:661:in `find_by_sql'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:1548:in `find_every'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:1505:in `find_initial'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/base.rb:692:in `exists?'
./db/migrate//20100523141204_create_medias_operatingsystems_and_migrate_data.rb:7:in `up_without_benchmarks'
./db/migrate//20100523141204_create_medias_operatingsystems_and_migrate_data.rb:5:in `each'
./db/migrate//20100523141204_create_medias_operatingsystems_and_migrate_data.rb:5:in `up_without_benchmarks'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `send'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `__send__'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `migrate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:486:in `migrate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `call'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `ddl_transaction'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:485:in `migrate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `each'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `migrate'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:400:in `up'
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'
/usr/share/foreman/vendor/rails/railties/lib/tasks/databases.rake:116
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:635:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:635:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:630:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:630:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:589:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:582:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2050:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2028:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2028:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2028:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2022:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1997:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Poking around, I found that the problem was references to family_id that should have been @family_id. Simple patch attached.
Files