Db:migrate 1.4.4 -> 1.5 failure

Hello,

I have followed the upgrade instructions from 1.4.4 to 1.5 and get a
'validation failed' error on the 'foreman-rake db:migrate' task

Can anyone provide a hint on getting past this?

Appreciate your response.

Cheers,

Ben Morrice

Output is below:

[ ~]# foreman-rake -v db:migrate
== CreateCachedUsergroupMembers: migrating

··· =================================== -- create_table(:cached_usergroup_members) NOTICE: CREATE TABLE will create implicit sequence "cached_usergroup_members_id_seq" for serial column "cached_usergroup_members.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "cached_usergroup_members_pkey" for table "cached_usergroup_members" -> 0.0116s -- add_index(:cached_usergroup_members, :user_id) -> 0.0030s -- add_index(:cached_usergroup_members, :usergroup_id) -> 0.0029s rake aborted! An error has occurred, this and all later migrations canceled:

Validation failed: Adding would cause a cycle!

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
[ ~]#

Trace is below:

[ ~]# foreman-rake -v db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== CreateCachedUsergroupMembers: migrating

– create_table(:cached_usergroup_members)
NOTICE: CREATE TABLE will create implicit sequence
"cached_usergroup_members_id_seq" for serial column
"cached_usergroup_members.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"cached_usergroup_members_pkey" for table “cached_usergroup_members”
-> 0.0037s
– add_index(:cached_usergroup_members, :user_id)
-> 0.0024s
– add_index(:cached_usergroup_members, :usergroup_id)
-> 0.0019s
rake aborted!
An error has occurred, this and all later migrations canceled:

Validation failed: Adding would cause a cycle!
/usr/share/foreman/lib/core_extensions.rb:90:in detect_cycle' /usr/share/foreman/lib/core_extensions.rb:77:inensure’
/usr/share/foreman/app/models/usergroup_member.rb:17:in ensure_no_cycle' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:418:in_run__197232453163765864__validation__4138096205087008851__callbacks’
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in
__run_callback' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in_run_validation_callbacks’
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in
run_callbacks' /opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/validations/callbacks.rb:53:inrun_validations!’
/opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/validations.rb:194:in
valid?' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:69:invalid?’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:77:in
perform_validations' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:56:insave!’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:33:in
save!' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:inblock in save!’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in
block in with_transaction_returning_status' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:intransaction’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in
transaction' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:inwith_transaction_returning_status’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in
save!' /usr/share/foreman/db/migrate/20131122170726_create_cached_usergroup_members.rb:13:ineach’
/usr/share/foreman/db/migrate/20131122170726_create_cached_usergroup_members.rb:13:in
change' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:407:inblock (2 levels) in migrate’
/opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in measure' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:407:inblock in migrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in
with_connection' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:389:inmigrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:528:in
migrate' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:720:inblock (2 levels) in migrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:in
call' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:inblock in ddl_transaction’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in
transaction' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:intransaction’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:in
ddl_transaction' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:719:inblock in migrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in
each' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:inmigrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in
up' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:inmigrate’
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in
block (2 levels) in <top (required)>' /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:incall’
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in block in execute' /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:ineach’
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in execute' /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:inblock in
invoke_with_call_chain’
/opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in mon_synchronize' /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:ininvoke_with_call_chain’
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in invoke' /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:ininvoke_task’
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block (2 levels) in top_level' /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:ineach’
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block in top_level' /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:instandard_exception_handling’
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in top_level' /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:inblock in run’
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling' /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:inrun’
/opt/rh/ruby193/root/usr/bin/rake:32:in `'
Tasks: TOP => db:migrate
[ ~]#

It looks like your user groups have a loop of some sort, i.e. user group
A has B as a member, which also has A as a member.

Please ensure these are removed in your Foreman 1.4.4 instance before
attempting a 1.5 upgrade. (I'd suggest reverting, removing the loop and
attempt the upgrade again.)

See also the upgrade prep notes:
http://theforeman.org/manuals/1.5/index.html#3.6Upgrade

··· -- Dominic Cleal Red Hat Engineering

On 14/05/14 10:16, bmorrice wrote:

Hello,

I have followed the upgrade instructions from 1.4.4 to 1.5 and get a
’validation failed’ error on the ‘foreman-rake db:migrate’ task

Can anyone provide a hint on getting past this?

Appreciate your response.

Cheers,

Ben Morrice

Output is below:

[ ~]# foreman-rake -v db:migrate
== CreateCachedUsergroupMembers: migrating

– create_table(:cached_usergroup_members)
NOTICE: CREATE TABLE will create implicit sequence
"cached_usergroup_members_id_seq" for serial column
"cached_usergroup_members.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"cached_usergroup_members_pkey" for table “cached_usergroup_members”
-> 0.0116s
– add_index(:cached_usergroup_members, :user_id)
-> 0.0030s
– add_index(:cached_usergroup_members, :usergroup_id)
-> 0.0029s
rake aborted!
An error has occurred, this and all later migrations canceled:

Validation failed: Adding would cause a cycle!

Thanks for your prompt reply, i'm sorted now.

Cheers,

Ben

··· On Wed, May 14, 2014 at 11:18 AM, Dominic Cleal wrote: > It looks like your user groups have a loop of some sort, i.e. user group > A has B as a member, which also has A as a member. > > Please ensure these are removed in your Foreman 1.4.4 instance before > attempting a 1.5 upgrade. (I'd suggest reverting, removing the loop and > attempt the upgrade again.) > > See also the upgrade prep notes: > http://theforeman.org/manuals/1.5/index.html#3.6Upgrade > > -- > Dominic Cleal > Red Hat Engineering > > On 14/05/14 10:16, bmorrice wrote: >> Hello, >> >> I have followed the upgrade instructions from 1.4.4 to 1.5 and get a >> 'validation failed' error on the 'foreman-rake db:migrate' task >> >> Can anyone provide a hint on getting past this? >> >> Appreciate your response. >> >> Cheers, >> >> Ben Morrice >> >> >> >> Output is below: >> >> [ ~]# foreman-rake -v db:migrate >> == CreateCachedUsergroupMembers: migrating >> =================================== >> -- create_table(:cached_usergroup_members) >> NOTICE: CREATE TABLE will create implicit sequence >> "cached_usergroup_members_id_seq" for serial column >> "cached_usergroup_members.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "cached_usergroup_members_pkey" for table "cached_usergroup_members" >> -> 0.0116s >> -- add_index(:cached_usergroup_members, :user_id) >> -> 0.0030s >> -- add_index(:cached_usergroup_members, :usergroup_id) >> -> 0.0029s >> rake aborted! >> An error has occurred, this and all later migrations canceled: >> >> Validation failed: Adding would cause a cycle! > > > -- > You received this message because you are subscribed to a topic in the Google Groups "Foreman users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/topic/foreman-users/dszCDmSfUaM/unsubscribe. > To unsubscribe from this group and all its topics, send an email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.