From fb96b33f98f96d848ed70a13a3eca8513c7be9d9 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Sun, 25 Aug 2024 10:19:15 -0400 Subject: [PATCH] Fix bad kits --- db/migrate/20240825141541_fix_bad_kits.rb | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 db/migrate/20240825141541_fix_bad_kits.rb diff --git a/db/migrate/20240825141541_fix_bad_kits.rb b/db/migrate/20240825141541_fix_bad_kits.rb new file mode 100644 index 0000000000..3aa7ade4be --- /dev/null +++ b/db/migrate/20240825141541_fix_bad_kits.rb @@ -0,0 +1,25 @@ +class FixBadKits < ActiveRecord::Migration[7.1] + def change + return unless Rails.env.production? + + ids = [78, 204,189] + kit_base_item = BaseItem.find_or_create_by!({ + name: 'Kit', + category: 'kit', + partner_key: 'kit' + }) + Kit.where(id: ids).each do |kit| + result = ItemCreateService.new( + organization_id: kit.organization.id, + item_params: { + name: kit.name, + partner_key: kit_base_item.partner_key, + kit_id: kit.id + } + ).call + unless result.success? + raise result.error + end + end + end +end