From e208e8927bca1f5ebdf7d1b70b2a8fac158d3803 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 30 Aug 2024 12:53:50 -0400 Subject: [PATCH 1/2] Revert "Merge pull request #749 from Fryguy/cleanup_migration_name" This reverts commit 3de3c4c7c041174c23aa719b424d0122bb4edcc7, reversing changes made to 2b2c76dea6087734579e6950786716a46a6f8c94. --- ...101409_updateresourcepoolidentifierstomiqproductfeatures.rb} | 2 +- ...9_updateresourcepoolidentifierstomiqproductfeatures_spec.rb} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename db/migrate/{20240516101409_update_resource_pool_identifiers_to_miq_product_features.rb => 20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb} (95%) rename spec/migrations/{20240516101409_update_resource_pool_identifiers_to_miq_product_features_spec.rb => 20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb} (95%) diff --git a/db/migrate/20240516101409_update_resource_pool_identifiers_to_miq_product_features.rb b/db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb similarity index 95% rename from db/migrate/20240516101409_update_resource_pool_identifiers_to_miq_product_features.rb rename to db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb index 45840f62..73187b6d 100644 --- a/db/migrate/20240516101409_update_resource_pool_identifiers_to_miq_product_features.rb +++ b/db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb @@ -1,4 +1,4 @@ -class UpdateResourcePoolIdentifiersToMiqProductFeatures < ActiveRecord::Migration[6.1] +class Updateresourcepoolidentifierstomiqproductfeatures < ActiveRecord::Migration[6.1] class MiqProductFeature < ActiveRecord::Base; end FEATURE_MAPPING_UPDATE = { diff --git a/spec/migrations/20240516101409_update_resource_pool_identifiers_to_miq_product_features_spec.rb b/spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb similarity index 95% rename from spec/migrations/20240516101409_update_resource_pool_identifiers_to_miq_product_features_spec.rb rename to spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb index d850c2d5..266cb465 100644 --- a/spec/migrations/20240516101409_update_resource_pool_identifiers_to_miq_product_features_spec.rb +++ b/spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb @@ -1,6 +1,6 @@ require_migration -describe UpdateResourcePoolIdentifiersToMiqProductFeatures do +describe Updateresourcepoolidentifierstomiqproductfeatures do let(:miq_product_feature) { migration_stub(:MiqProductFeature) } before do From 064edc29e2eae32295640e8765146ec1affbd22a Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 30 Aug 2024 12:53:55 -0400 Subject: [PATCH 2/2] Revert "Merge pull request #718 from Guddetisandeep/update_resource_pool_identifiers" This reverts commit 2b2c76dea6087734579e6950786716a46a6f8c94, reversing changes made to 075c33a57665452d15657fdc60bb0b62c741212c. --- ...urcepoolidentifierstomiqproductfeatures.rb | 35 ----------------- ...oolidentifierstomiqproductfeatures_spec.rb | 39 ------------------- 2 files changed, 74 deletions(-) delete mode 100644 db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb delete mode 100644 spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb diff --git a/db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb b/db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb deleted file mode 100644 index 73187b6d..00000000 --- a/db/migrate/20240516101409_updateresourcepoolidentifierstomiqproductfeatures.rb +++ /dev/null @@ -1,35 +0,0 @@ -class Updateresourcepoolidentifierstomiqproductfeatures < ActiveRecord::Migration[6.1] - class MiqProductFeature < ActiveRecord::Base; end - - FEATURE_MAPPING_UPDATE = { - 'resource_pool' => 'resource_pool_infra', - 'resource_pool_view' => 'resource_pool_infra_view', - 'resource_pool_show_list' => 'resource_pool_infra_show_list', - 'resource_pool_show' => 'resource_pool_infra_show', - 'resource_pool_control' => 'resource_pool_infra_control', - 'resource_pool_tag' => 'resource_pool_infra_tag', - 'resource_pool_protect' => 'resource_pool_infra_protect', - 'resource_pool_admin' => 'resource_pool_infra_admin', - 'resource_pool_delete' => 'resource_pool_infra_delete' - }.freeze - - def up - return if MiqProductFeature.none? - - say_with_time('Updating resource_pool features to resource_pool_infra') do - FEATURE_MAPPING_UPDATE.each do |from, to| - MiqProductFeature.find_by(:identifier => from)&.update!(:identifier => to) - end - end - end - - def down - return if MiqProductFeature.none? - - say_with_time('Reverting resource_pool_infra features back to resource_pool') do - FEATURE_MAPPING_UPDATE.each do |to, from| - MiqProductFeature.find_by(:identifier => from)&.update!(:identifier => to) - end - end - end -end diff --git a/spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb b/spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb deleted file mode 100644 index 266cb465..00000000 --- a/spec/migrations/20240516101409_updateresourcepoolidentifierstomiqproductfeatures_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_migration - -describe Updateresourcepoolidentifierstomiqproductfeatures do - let(:miq_product_feature) { migration_stub(:MiqProductFeature) } - - before do - %w[resource_pool resource_pool_view resource_pool_show_list resource_pool_show resource_pool_control resource_pool_tag resource_pool_protect resource_pool_admin resource_pool_delete].each do |identifier| - miq_product_feature.create!(:identifier => identifier) - end - end - - migration_context :up do - it "updates existing resource_pool features to resource_pool_infra" do - migrate - - described_class::FEATURE_MAPPING_UPDATE.each do |old_identifier, new_identifier| - expect(miq_product_feature.exists?(:identifier => old_identifier)).to be_falsy - expect(miq_product_feature.exists?(:identifier => new_identifier)).to be_truthy - end - end - end - - migration_context :down do - before do - described_class::FEATURE_MAPPING_UPDATE.each do |_old_identifier, new_identifier| - miq_product_feature.create!(:identifier => new_identifier) - end - end - - it "reverts resource_pool_infra features back to resource_pool" do - migrate - - described_class::FEATURE_MAPPING_UPDATE.each do |old_identifier, new_identifier| - expect(miq_product_feature.exists?(:identifier => new_identifier)).to be_falsy - expect(miq_product_feature.exists?(:identifier => old_identifier)).to be_truthy - end - end - end -end