Project

General

Profile

Actions

Bug #10603

closed

foreman-rake db:migrate fails with Table 'foreman.user_compute_resources' doesn't exist

Added by rui fernandes almost 9 years ago. Updated almost 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

when I try to run "foreman-rake db:migrate" it errors out. Table 'foreman.user_compute_resources' doesn't exist

I don't see the table "user_compute_resources" ..

  1. foreman-rake db:migrate --trace
    • Invoke db:migrate (first_time)
    • Invoke environment (first_time)
    • Execute environment
    • Invoke db:load_config (first_time)
    • Execute db:load_config
    • Execute db:migrate
      DeleteOrphanedRecords: migrating ========================================
      -- execute("DELETE FROM architectures_operatingsystems WHERE architecture_id NOT IN (SELECT id FROM architectures) OR operatingsystem_id NOT IN (SELECT id FROM operatingsystems)")
      > 0.0003s
      -
      execute("DELETE FROM config_templates_operatingsystems WHERE config_template_id NOT IN (SELECT id FROM config_templates) OR operatingsystem_id NOT IN (SELECT id FROM operatingsystems)")
      > 0.0003s
      -
      execute("DELETE FROM features_smart_proxies WHERE feature_id NOT IN (SELECT id FROM features) OR smart_proxy_id NOT IN (SELECT id FROM smart_proxies)")
      > 0.0003s
      -
      execute("DELETE FROM features_smart_proxies WHERE feature_id NOT IN (SELECT id FROM features) OR smart_proxy_id NOT IN (SELECT id FROM smart_proxies)")
      > 0.0002s
      -
      execute("DELETE FROM media_operatingsystems WHERE medium_id NOT IN (SELECT id FROM media) OR operatingsystem_id NOT IN (SELECT id FROM operatingsystems)")
      > 0.0002s
      -
      execute("DELETE FROM operatingsystems_ptables WHERE ptable_id NOT IN (SELECT id FROM ptables) OR operatingsystem_id NOT IN (SELECT id FROM operatingsystems)")
      > 0.0004s
      -
      execute("DELETE FROM operatingsystems_puppetclasses WHERE puppetclass_id NOT IN (SELECT id FROM puppetclasses) OR operatingsystem_id NOT IN (SELECT id FROM operatingsystems)")
      > 0.0003s
      -
      execute("DELETE FROM subnet_domains WHERE domain_id NOT IN (SELECT id FROM domains) OR subnet_id NOT IN (SELECT id FROM subnets)")
      > 0.0004s
      -
      execute("DELETE FROM user_compute_resources WHERE compute_resource_id NOT IN (SELECT id FROM compute_resources) OR user_id NOT IN (SELECT id FROM users)")
      rake aborted!
      An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'foreman.user_compute_resources' doesn't exist: DELETE FROM user_compute_resources WHERE compute_resource_id NOT IN (SELECT id FROM compute_resources) OR user_id NOT IN (SELECT id FROM users)
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:466:in `block in method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `block in say_with_time'
/opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in `measure'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `say_with_time'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:458:in `method_missing'
/usr/share/foreman/db/migrate/20130908100439_delete_orphaned_records.rb:12:in `up'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in `measure'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:389:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:528:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `ddl_transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:719:in `block in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `up'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `block in execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in `block in invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in `invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in `invoke'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2 levels) in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in run'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
/opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
Tasks: TOP => db:migrate

Actions #1

Updated by rui fernandes almost 9 years ago

I was able to move pass this by removing the line from 20130908100439_delete_orphaned_records.rb

Actions #2

Updated by rui fernandes almost 9 years ago

the were multiple of these types of errors while running: foreman-rake db:migrate

several duplicate column name errors, removing indexes which did exist.
My strategy was to verify the database and skip that like in the .rb file.

in the end, foreman-rake db:migrate and foreman-rake db:seed completed.

foreman is up, I don't see any errors. So, hopefully I did not break anything.

I had to modify the following files:
rw-r--r- 1 root root 7628 May 23 14:22 20130908100439_delete_orphaned_records.rb
rw-r--r- 1 root root 2431 May 23 15:26 20140910153654_move_host_nics_to_interfaces.rb
rw-r--r- 1 root root 114 May 23 15:32 20141120140051_remove_audit_user_fk.rb
rw-r--r- 1 root root 998 May 23 15:38 20150508124600_copy_unmanaged_hosts_to_interfaces.rb

Actions #3

Updated by Dominic Cleal almost 9 years ago

  • Status changed from New to Resolved

Glad you got it sorted!

Actions

Also available in: Atom PDF