Project

General

Profile

Actions

Bug #13242

closed

db:migrate fails under Rails 4.1.latest with "katello_key_system_groups_pkey" not found

Added by Dominic Cleal almost 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Under Rails 4.1.9 or higher, the db:migrate fails with Katello loaded:

13:41:15 == 20140502164009 RenameSystemGroupsToHostCollections: migrating ==============
13:41:15 -- rename_index(:katello_key_system_groups, "katello_key_system_groups_pkey", "katello_key_host_collections_pkey")
13:41:15    -> 0.0007s
13:41:15 -- rename_index(:katello_key_system_groups, "index_key_system_groups_on_activation_key_id", "index_key_host_collections_on_activation_key_id")
13:41:15    -> 0.0004s
13:41:15 -- rename_index(:katello_key_system_groups, "index_key_system_groups_on_system_group_id", "index_key_host_collections_on_host_collection_id")
13:41:15    -> 0.0004s
13:41:15 -- rename_column(:katello_key_system_groups, :system_group_id, :host_collection_id)
13:41:15    -> 0.0025s
13:41:15 -- rename_table(:katello_key_system_groups, :katello_key_host_collections)
13:41:15 rake aborted!
13:41:15 StandardError: An error has occurred, this and all later migrations canceled:
13:41:15 
13:41:15 PG::Error: ERROR:  relation "katello_key_system_groups_pkey" does not exist
13:41:15 : ALTER INDEX "katello_key_system_groups_pkey" RENAME TO "katello_key_host_collections_pkey"/usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/abstract_adapter.rb:378:in `block in log'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activesupport-4.1.14/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/abstract_adapter.rb:372:in `log'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/connection_adapters/postgresql/schema_statements.rb:388:in `rename_table'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/migration.rb:656:in `block in method_missing'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/migration.rb:628:in `block in say_with_time'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/migration.rb:628:in `say_with_time'
13:41:15 /usr/local/rvm/gems/ruby-1.9.3-p392@test_katello_core-2/gems/activerecord-4.1.14/lib/active_record/migration.rb:648:in `method_missing'
13:41:15 /var/lib/workspace/workspace/test_katello_core/database/postgresql/ruby/1.9.3/slave/fast/plugin/db/migrate/20140502164009_rename_system_groups_to_host_collections.rb:7:in `change'

4.1.9 and higher rename the primary key index automatically, so the earlier rename is not required (under .9+ at least). Perhaps move it to after the table rename, and rename only if it exists under the old name.


Related issues 1 (0 open1 closed)

Blocks Foreman - Feature #12873: Update Rails to 4.1.latestClosedDominic Cleal12/18/2015Actions
Actions

Also available in: Atom PDF