Skip to content

Commit 636b547

Browse files
committed
Drop log collection tables, columns, and configuration
1 parent ce2f766 commit 636b547

File tree

5 files changed

+118
-4
lines changed

5 files changed

+118
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class DropLogCollectionBackend < ActiveRecord::Migration[7.2]
2+
def up
3+
remove_column :miq_servers, :log_file_depot_id
4+
remove_column :zones, :log_file_depot_id
5+
6+
drop_table :log_files
7+
8+
remove_column :file_depots, :support_case
9+
end
10+
11+
def down
12+
create_table :log_files do |t|
13+
t.string :name
14+
t.string :description
15+
t.string :resource_type
16+
t.bigint :resource_id
17+
t.bigint :miq_task_id
18+
t.datetime :created_on, :precision => nil
19+
t.datetime :updated_on, :precision => nil
20+
t.datetime :logging_started_on, :precision => nil
21+
t.datetime :logging_ended_on, :precision => nil
22+
t.string :state
23+
t.boolean :historical
24+
t.string :log_uri
25+
t.bigint :file_depot_id
26+
t.string :local_file
27+
t.index [:miq_task_id], :name => "index_log_files_on_miq_task_id"
28+
t.index [:resource_id, :resource_type], :name => "index_log_files_on_resource_id_and_resource_type"
29+
end
30+
31+
add_column :miq_servers, :log_file_depot_id, :bigint
32+
add_column :zones, :log_file_depot_id, :bigint
33+
34+
add_column :file_depots, :support_case, :string
35+
end
36+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class DropLogCollectionConfiguration < ActiveRecord::Migration[7.2]
2+
class MiqProductFeature < ActiveRecord::Base
3+
include ActiveRecord::IdRegions
4+
end
5+
6+
class MiqRolesFeature < ActiveRecord::Base
7+
include ActiveRecord::IdRegions
8+
end
9+
10+
class SettingsChange < ActiveRecord::Base
11+
include ActiveRecord::IdRegions
12+
end
13+
14+
FEATURE_NAMES = %w[
15+
collect_current_logs
16+
collect_logs
17+
log_depot_edit
18+
zone_collect_current_logs
19+
zone_collect_logs
20+
zone_log_depot_edit
21+
].freeze
22+
23+
def up
24+
say_with_time("Removing log collection product features") do
25+
MiqProductFeature.in_my_region.where(:identifier => FEATURE_NAMES).each do |feature|
26+
MiqRolesFeature.where(:miq_product_feature_id => feature.id).delete_all
27+
feature.delete
28+
end
29+
end
30+
31+
say_with_time("Removing log collection settings") do
32+
SettingsChange.in_my_region.where("key LIKE ?", "/log/collection%").delete_all
33+
end
34+
end
35+
end

spec/automated_review/foreign_key_columns_have_indexes_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
iso_images.pxe_image_type_id
145145
key_pairs_vms.authentication_id
146146
lans.parent_id
147-
log_files.file_depot_id
148147
metric_rollups_01.parent_ems_cluster_id
149148
metric_rollups_01.parent_ems_id
150149
metric_rollups_01.parent_host_id
@@ -361,7 +360,6 @@
361360
miq_roles_features.miq_product_feature_id
362361
miq_schedules.file_depot_id
363362
miq_schedules.resource_id
364-
miq_servers.log_file_depot_id
365363
miq_set_memberships.member_id
366364
miq_widget_contents.miq_group_id
367365
miq_widget_shortcuts.miq_shortcut_id
@@ -442,7 +440,6 @@
442440
vms.storage_profile_id
443441
windows_images.pxe_image_type_id
444442
windows_images.pxe_server_id
445-
zones.log_file_depot_id
446443
])
447444
end
448445

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require_migration
2+
3+
class DropLogCollectionConfiguration < ActiveRecord::Migration[7.2]
4+
class MiqUserRole < ActiveRecord::Base; end
5+
end
6+
7+
describe DropLogCollectionConfiguration do
8+
let(:miq_product_feature_stub) { migration_stub(:MiqProductFeature) }
9+
let(:miq_roles_feature_stub) { migration_stub(:MiqRolesFeature) }
10+
let(:miq_user_role_stub) { migration_stub(:MiqUserRole) }
11+
12+
let(:settings_change_stub) { migration_stub(:SettingsChange) }
13+
14+
migration_context :up do
15+
it "deletes product features" do
16+
features = described_class::FEATURE_NAMES.map do |feature|
17+
miq_product_feature_stub.find_or_create_by!(:identifier => feature)
18+
end
19+
features << miq_product_feature_stub.create!(:identifier => "other_feature")
20+
21+
role = miq_user_role_stub.create!(:name => "role1")
22+
role_features = features.map do |f|
23+
miq_roles_feature_stub.create!(:miq_user_role_id => role.id, :miq_product_feature_id => f.id)
24+
end
25+
other_role_feature = role_features.last
26+
27+
expect(miq_roles_feature_stub.count).to eq(features.length)
28+
29+
migrate
30+
31+
expect(miq_roles_feature_stub.count).to eq(1)
32+
expect(miq_roles_feature_stub.all).to eq([other_role_feature])
33+
expect(miq_product_feature_stub.where(:identifier => "other_feature").count).to eq(1)
34+
expect(miq_product_feature_stub.where(:identifier => "collect_logs").count).to eq(0)
35+
end
36+
37+
it "deletes settings" do
38+
keep = settings_change_stub.create!(:key => "/log/level", :value => "debug")
39+
to_delete = settings_change_stub.create!(:key => "/log/collection/ping_depot", :value => "false")
40+
41+
migrate
42+
43+
expect(settings_change_stub.count).to eq(1)
44+
expect(settings_change_stub.first).to eq(keep)
45+
end
46+
end
47+
end

spec/support/table_list.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ load_balancer_pool_member_pools
141141
load_balancer_pool_members
142142
load_balancer_pools
143143
load_balancers
144-
log_files
145144
metric_rollups_01
146145
metric_rollups_02
147146
metric_rollups_03

0 commit comments

Comments
 (0)