Project

General

Profile

Bug #8366

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

Added by Ronald van Zantvoort over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
High
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
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

Related to Foreman - Bug #6695: Adding two OS parameters with same name doesn't raise any error when values are differentClosed2014-07-20

Associated revisions

Revision d5f92b39 (diff)
Added by Dominic Cleal over 4 years ago

fixes #8366 - add parameter type to unique index

Revision 6db98d62 (diff)
Added by Dominic Cleal over 4 years ago

fixes #8366 - add parameter type to unique index

(cherry picked from commit d5f92b39de44658f2c73ff87139f7152e6e41208)

History

#1 Updated by Dominic Cleal over 4 years ago

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

#2 Updated by Dominic Cleal over 4 years ago

  • Target version set to 1.7.2

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

#3 Updated by Ori Rabin over 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Ori Rabin

#4 Updated by The Foreman Bot over 4 years ago

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

#5 Updated by Dominic Cleal over 4 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!

#6 Updated by Dominic Cleal over 4 years ago

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

#7 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) changed from 21 to 30

Also available in: Atom PDF