From 3382a5eeaab050ff113174144f23a1aea832f325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 7 Aug 2024 10:55:35 +0200 Subject: [PATCH] Fix lookup of journal_class, not only table --- db/migrate/20220818074159_fix_deleted_data_journals.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrate/20220818074159_fix_deleted_data_journals.rb b/db/migrate/20220818074159_fix_deleted_data_journals.rb index d479affcf84a..45a5d7840163 100644 --- a/db/migrate/20220818074159_fix_deleted_data_journals.rb +++ b/db/migrate/20220818074159_fix_deleted_data_journals.rb @@ -116,7 +116,7 @@ def get_missing_journals Journal .pluck("DISTINCT(journable_type)") .to_h do |journable_type| - table_name = lookup_journal_class_table(journable_type) + journal_class, table_name = lookup_journal_class_table(journable_type) relation = Journal .joins("LEFT OUTER JOIN #{table_name} ON journals.data_type = '#{journal_class}' AND #{table_name}.id = journals.data_id") .where("#{table_name}.id IS NULL") @@ -131,10 +131,10 @@ def get_missing_journals # Lookup table for items that were already deleted def lookup_journal_class_table(journable_type) - lookup = { "WikiContent" => "wiki_content_journals" } + lookup = { "WikiContent" => %w[Journal::WikiContentJournal wiki_content_journals] } lookup.fetch(journable_type) do journal_class = journable_type.constantize.journal_class - journal_class.table_name + [journal_class.to_s, journal_class.table_name] end end