Project

General

Profile

Actions

Bug #8366

closed

Upgrade from 1.6.2 to 1.7rc1 fails during AddUniqueIndexToParameter db migration with duplicate key error

Added by Ronald van Zantvoort over 9 years ago. Updated over 5 years ago.

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

Description

Upgrading our Foreman instance from 1.6.2 to 1.7rc1 fails during migration of the DB with the following error:

==  AddUniqueIndexToParameter: migrating ======================================
-- add_index(:parameters, [:reference_id, :name], {:unique=>true})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Duplicate entry '4-lag-members' for key 'index_parameters_on_reference_id_and_name': CREATE UNIQUE INDEX `index_parameters_on_reference_id_and_name` ON `parameters` (`reference_id`, `name`)/usr/share/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
(etc...)

This is caused by 20140805114754_add_unique_index_to_parameter.rb trying to add the mentioned index. However, in my db, I have:

id   name         ref_id      type
1    lag-members    4         GroupParameter
3    lag-members    4         HostParameter

Which leads to the SQL violation.
So it looks like anyone upgrading who has the same parameter set on both Group and Host might suffer this problem?


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #6695: Adding two OS parameters with same name doesn't raise any error when values are differentClosedOri Rabin07/20/2014Actions
Actions #1

Updated by Dominic Cleal over 9 years ago

  • Related to Bug #6695: Adding two OS parameters with same name doesn't raise any error when values are different added
Actions #2

Updated by Dominic Cleal over 9 years ago

  • Target version set to 1.7.2

Looks like the 'type' should be part of the index, thanks for the report!

Actions #3

Updated by Ori Rabin over 9 years ago

  • Status changed from New to Assigned
  • Assignee set to Ori Rabin
Actions #4

Updated by The Foreman Bot over 9 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/1927 added
  • Pull request deleted ()
Actions #5

Updated by Dominic Cleal over 9 years ago

  • Assignee changed from Ori Rabin to Dominic Cleal

Sorry Ori, I thought I'd set assignee but it didn't happen. PR's up if you'd like to review it. If you have another solution, we can compare answers!

Actions #6

Updated by Dominic Cleal over 9 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #7

Updated by Dominic Cleal about 9 years ago

  • translation missing: en.field_release changed from 21 to 30
Actions

Also available in: Atom PDF