Upgrade from 3.0 to 3.1.1

Problem:
Running foreman-rake db:migrate trigger an error

Expected outcome:
No errors and database migrated

Foreman and Proxy versions:
From 3.0 to 3.1.1

Foreman and Proxy plugin versions:
foreman_hooks 0.3.17
foreman-openstack 3.0.1-2
foreman-ec2 3.0.1-2
foreman-vmware 3.0.1-2

Distribution and version:
Ubuntu 20.04 (using packages from deb.theforeman.org)

Other relevant data:

foreman-rake db:migrate --trace

** Invoke db:migrate (first_time)

** Invoke db:load_config (first_time)

** Invoke environment (first_time)

** Execute environment

** Execute db:load_config

** Invoke plugin:refresh_migrations (first_time)

** Invoke environment

** Execute plugin:refresh_migrations

** Execute db:migrate

== 20090905150132 CreateHostgroupsPuppetclasses: migrating ====================

-- create_table(:hostgroups_puppetclasses, {:id=>false, :if_not_exists=>true})

rake aborted!

StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR: relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `exec'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/schema_statements.rb:443:in `add_index'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:319:in `block in create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:890:in `block in method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `block in say_with_time'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `say_with_time'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:879:in `method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/foreman_puppet-2.0.0/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb:3:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `block in ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in `with_advisory_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

/usr/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'

/usr/bin/rake:27:in `<main>'

Caused by:

ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR: relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `exec'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/schema_statements.rb:443:in `add_index'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:319:in `block in create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:890:in `block in method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `block in say_with_time'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `say_with_time'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:879:in `method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/foreman_puppet-2.0.0/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb:3:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `block in ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in `with_advisory_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

/usr/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'

/usr/bin/rake:27:in `<main>'

Caused by:

PG::DuplicateTable: ERROR: relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `exec'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/schema_statements.rb:443:in `add_index'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:319:in `block in create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `create_table'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:890:in `block in method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `block in say_with_time'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `say_with_time'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:879:in `method_missing'

/usr/share/foreman/vendor/ruby/2.5.0/gems/foreman_puppet-2.0.0/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb:3:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'

/usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `block in ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `ddl_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `migrate_without_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `block in migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in `with_advisory_lock'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in `up'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in `migrate'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

/usr/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'

/usr/share/foreman/vendor/ruby/2.5.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'

/usr/bin/rake:27:in `<main>'

Tasks: TOP => db:migrate

Bonjour,

We have the same problem with centos 7 or 8 ( Upgrade to 3.1 - db:migrate fails with PG::DuplicateTable )

Thank you

Regards,

Frederic

Bonjour,

Problem fixed here Upgrade to 3.1 - db:migrate fails with PG::DuplicateTable

Regards,

Frederic