0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-18 23:01:11 +02:00
discourse-custom-wizard/db/migrate/20200718014105_update_watch_categories_action.rb

29 Zeilen
767 B
Ruby

2021-03-11 07:30:15 +01:00
# frozen_string_literal: true
2020-07-20 05:06:36 +02:00
class UpdateWatchCategoriesAction < ActiveRecord::Migration[6.0]
def change
watch_category_wizards = PluginStoreRow.where("
plugin_name = 'custom_wizard' AND
value::jsonb -> 'actions' @> '[{ \"type\" : \"watch_categories\" }]'::jsonb
")
2021-03-11 07:30:15 +01:00
2020-07-20 05:06:36 +02:00
if watch_category_wizards.exists?
watch_category_wizards.each do |row|
begin
wizard_json = JSON.parse(row.value)
rescue TypeError, JSON::ParserError
next
2021-03-11 07:30:15 +01:00
end
2020-07-20 05:06:36 +02:00
wizard_json['actions'].each do |a|
if a['type'] === "watch_categories" && a['wizard_user'] == nil
a['wizard_user'] = true
end
end
2021-03-11 07:30:15 +01:00
2020-07-20 05:06:36 +02:00
row.value = wizard_json.to_json
row.save
end
end
end
2021-03-11 07:30:15 +01:00
end