Bug 1793112 - DB Migrate fails from 4.7 to 5.0
Summary: DB Migrate fails from 4.7 to 5.0
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.11.1
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: GA
: 5.12.0
Assignee: drew uhlmann
QA Contact: Jaroslav Henner
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks: 1806556
TreeView+ depends on / blocked
 
Reported: 2020-01-20 17:28 UTC by David Luong
Modified: 2020-10-26 16:13 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1806556 (view as bug list)
Environment:
Last Closed: 2020-10-26 16:13:44 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:
mfeifer: mirror+


Attachments (Terms of Use)

Description David Luong 2020-01-20 17:28:22 UTC
Description of problem:
DB Migrate from 4.7 to 5.0 fails

Version-Release number of selected component (if applicable):
5.11.1

How reproducible:
Always (with my database)

Steps to Reproduce:
1.  Import db
2.  rails db:migrate
3.

Actual results:
rails db:migrate
== 20181016140921 MigrateOrchStacksToHaveOwnershipConcept: migrating ==========
-- Migrating existing orchestration stacks to have direct owners, groups, tenant
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined method `tenant_identity' for nil:NilClass
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:118:in `block (2 levels) in up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `block (2 levels) in find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `block in find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:129:in `block in find_in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:230:in `block in in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:214:in `loop'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:214:in `in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:128:in `find_in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:62:in `find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/querying.rb:9:in `find_each'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:114:in `block in up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:818:in `block in say_with_time'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:818:in `say_with_time'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:113:in `up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:795:in `exec_migration'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:776:in `block (2 levels) in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:775:in `block in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `with_connection'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:774:in `migrate'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:6:in `block in migrate'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:18:in `clearing_caches'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:5:in `migrate'
/var/www/miq/vmdb/lib/extensions/ar_migration.rb:88:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:953:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1230:in `block in execute_migration_in_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1298:in `block in ddl_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/transactions.rb:210:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1298:in `ddl_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1200:in `each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1148:in `block in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1148:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1007:in `up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:985:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/command.rb:46:in `invoke'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
NoMethodError: undefined method `tenant_identity' for nil:NilClass
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:118:in `block (2 levels) in up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `block (2 levels) in find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:63:in `block in find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:129:in `block in find_in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:230:in `block in in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:214:in `loop'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:214:in `in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:128:in `find_in_batches'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/relation/batches.rb:62:in `find_each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/querying.rb:9:in `find_each'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:114:in `block in up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:818:in `block in say_with_time'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:818:in `say_with_time'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb:113:in `up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:795:in `exec_migration'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:776:in `block (2 levels) in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:775:in `block in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `with_connection'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:774:in `migrate'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:6:in `block in migrate'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:18:in `clearing_caches'
/opt/rh/cfme-gemset/bundler/gems/cfme-schema-1af78b5e1cc9/lib/manageiq/schema/migrate_with_cleared_schema_cache.rb:5:in `migrate'
/var/www/miq/vmdb/lib/extensions/ar_migration.rb:88:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:953:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1230:in `block in execute_migration_in_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1298:in `block in ddl_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/transactions.rb:210:in `transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1298:in `ddl_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1200:in `each'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1148:in `block in migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1148:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:1007:in `up'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/migration.rb:985:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/opt/rh/cfme-gemset/gems/activerecord-5.1.7/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/command.rb:46:in `invoke'
/opt/rh/cfme-gemset/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

Expected results:
Migrates successfully

Additional info:
Workaround was to comment out the elsif statement in the migrate script:
#               elsif !stack.ems_id.nil?
#                 stack.ext_management_system.tenant_identity

Comment 3 CFME Bot 2020-01-31 23:39:19 UTC
New commit detected on ManageIQ/manageiq-schema/master:

https://github.com/ManageIQ/manageiq-schema/commit/2892cd6fce64cda23cd6d3457b3ab9cffb08f576
commit 2892cd6fce64cda23cd6d3457b3ab9cffb08f576
Author:     d-m-u <duhlmann>
AuthorDate: Tue Jan 21 05:50:50 2020 -0500
Commit:     d-m-u <duhlmann>
CommitDate: Tue Jan 21 05:50:50 2020 -0500

    Fix issue with orch stacks still having references to deleted ems

    Introduced in https://github.com/ManageIQ/manageiq-schema/pull/288

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1793112

 db/migrate/20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb | 2 +-
 spec/migrations/20181016140921_migrate_orch_stacks_to_have_ownership_concept_spec.rb | 10 +
 2 files changed, 11 insertions(+), 1 deletion(-)


Note You need to log in before you can comment on or make changes to this bug.