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 about 10 years ago. Updated over 6 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

Also available in: Atom PDF