-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data Migration: Ansible Tower Configuration Manager type to Automation Manager #13720
Conversation
@miq-bot add_labels providers/ansible_tower, enhancement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget about all of the other STI subclasses that were renamed by #13630
|
||
def up | ||
say_with_time("Migrating STI_type_of ansible_tower_configuration_managers to automation_managers") do | ||
ExtManagementSystem.where(:type => 'ManageIQ::Providers::AnsibleTower::ConfigurationManager').each do |manager| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use .each
in this context, prefer .update_all
ExtManagementSystem.where(
:type => 'ManageIQ::Providers::AnsibleTower::ConfigurationManager'
).update_all(
:type => 'ManageIQ::Providers::AnsibleTower::AutomationManager'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thanks, done!
|
||
def down | ||
say_with_time("Migrating STI_type_of ansible_tower_automation_managers to configuration_managers") do | ||
ExtManagementSystem.where(:type => 'ManageIQ::Providers::AnsibleTower::AutomationManager').each do |manager| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same .update_all
8ffc3bc
to
539f13a
Compare
Are there any polymorphic tables that also need to be updated? We have a helper for that |
There is an |
539f13a
to
a0308f9
Compare
The
We don't need to change those, right? |
@jameswnl Correct, those are base class so those are fine. |
|
||
class ExtManagementSystem < ActiveRecord::Base | ||
self.inheritance_column = :_type_disabled | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I take it out, spec will fail as follows. How to fix it?
1) MigrateAnsibleTowerConfigurationManagerStiTypeToAutomationManager#down migrates Ansible Tower Automation Manager to Configuration Manager type
Failure/Error: configuration_manager = ExtManagementSystem.find(automation_manager.id)
ActiveRecord::SubclassNotFound:
Invalid single-table inheritance type: ManageIQ::Providers::AnsibleTower::ConfigurationManager is not a subclass of ExtManagementSystem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So once I changed to the configuration_manager.reload.type
, the above error won't happen even without the definition of ExtManagementSystem
here now.
Removed now. Thanks
|
||
migrate | ||
|
||
automation_manager = ExtManagementSystem.find(configuration_manager.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not need this...just do a .reload
on configuration_manager:
expect(configuration_manager.reload.type).to eq('ManageIQ::Providers::AnsibleTower::AutomationManager')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks
You may also want a test that shows that other existing providers are not affected by this change. |
2afb214
to
1c7866c
Compare
@Fryguy thanks for reminding. Had that in mind but then it slipped. Now added. |
3e3f353
to
70da838
Compare
…tem to be of AutomationManager
70da838
to
4057951
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget about Job
and InventoryGroup
@bdunne thanks! Done. |
4540d2d
to
70faf84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I feel like the tests could be consolidated to only call migrate once per migration_context
, but I'm not going to reject it because of that.
This is okay in this context because it's a migration, so:
|
@bdunne I've consolidated the specs. |
97994c2
to
ed1bb5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bdunne if I don't get to it first, please merge when green.
Checked commits jameswnl/manageiq@23ccd69~...ed1bb5f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 db/migrate/20170131160216_migrate_ansible_tower_configuration_manager_sti_type_to_automation_manager.rb
|
Existing AnsibleTower Configruration Manager in the
ext_management_systems
table will be modified to have the new automation manager type.