From 45dbe841beb89e1b18d737ffb83aa20bc2d1c8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 5 Aug 2024 13:15:45 +0200 Subject: [PATCH] Rewrite migration using plain SQL https://community.openproject.org/work_packages/56043 --- ...20211117195121_remove_destroyed_help_texts.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/migrate/20211117195121_remove_destroyed_help_texts.rb b/db/migrate/20211117195121_remove_destroyed_help_texts.rb index 01f24e1c5985..ad219639e5b7 100644 --- a/db/migrate/20211117195121_remove_destroyed_help_texts.rb +++ b/db/migrate/20211117195121_remove_destroyed_help_texts.rb @@ -28,14 +28,14 @@ class RemoveDestroyedHelpTexts < ActiveRecord::Migration[6.1] def up - custom_field_ids = CustomField - .pluck(:id) - .map { |id| "custom_field_#{id}" } - - AttributeHelpText - .where("attribute_name LIKE 'custom_field_%'") - .where.not(attribute_name: custom_field_ids) - .destroy_all + execute <<~SQL + DELETE FROM attribute_help_texts + WHERE attribute_name LIKE 'custom_field_%' + AND attribute_name NOT IN ( + SELECT CONCAT('custom_field_', id) + FROM custom_fields + ) + SQL end def down