From 64567d9766b5f9c3a9c79469768448649ed1f1b4 Mon Sep 17 00:00:00 2001 From: Nat Date: Tue, 25 Mar 2025 17:02:18 +0800 Subject: [PATCH] Bound by custom field name --- ...d_topic_custom_field_to_discourse_solved_solved_topics.rb | 5 ++++- ...d_topic_custom_field_to_discourse_solved_solved_topics.rb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/db/migrate/20250318024953_copy_solved_topic_custom_field_to_discourse_solved_solved_topics.rb b/db/migrate/20250318024953_copy_solved_topic_custom_field_to_discourse_solved_solved_topics.rb index 2314b6f..a76d2b2 100644 --- a/db/migrate/20250318024953_copy_solved_topic_custom_field_to_discourse_solved_solved_topics.rb +++ b/db/migrate/20250318024953_copy_solved_topic_custom_field_to_discourse_solved_solved_topics.rb @@ -6,7 +6,10 @@ class CopySolvedTopicCustomFieldToDiscourseSolvedSolvedTopics < ActiveRecord::Mi BATCH_SIZE = 10_000 def up - max_id = DB.query_single("SELECT MAX(id) FROM topic_custom_fields").first + max_id = + DB.query_single( + "SELECT MAX(id) FROM topic_custom_fields WHERE topic_custom_fields.name = 'accepted_answer_post_id'", + ).first return unless max_id last_id = 0 diff --git a/db/migrate/20250325074111_copy_remaining_solved_topic_custom_field_to_discourse_solved_solved_topics.rb b/db/migrate/20250325074111_copy_remaining_solved_topic_custom_field_to_discourse_solved_solved_topics.rb index 398d9b7..25adfab 100644 --- a/db/migrate/20250325074111_copy_remaining_solved_topic_custom_field_to_discourse_solved_solved_topics.rb +++ b/db/migrate/20250325074111_copy_remaining_solved_topic_custom_field_to_discourse_solved_solved_topics.rb @@ -8,7 +8,10 @@ class CopyRemainingSolvedTopicCustomFieldToDiscourseSolvedSolvedTopics < ActiveR BATCH_SIZE = 5000 def up - max_id = DB.query_single("SELECT MAX(id) FROM topic_custom_fields").first + max_id = + DB.query_single( + "SELECT MAX(id) FROM topic_custom_fields WHERE topic_custom_fields.name = 'accepted_answer_post_id'", + ).first return unless max_id last_id = 0