Split create and copy

This commit is contained in:
Nat 2025-03-21 11:44:47 +08:00
parent 8036f5b4b2
commit 7d6611def6
No known key found for this signature in database
GPG Key ID: 4938B35D927EC773
2 changed files with 14 additions and 9 deletions

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
#
class CreateDiscourseSolvedSolvedTopics < ActiveRecord::Migration[7.2]
def change
create_table :discourse_solved_solved_topics do |t|
t.integer :topic_id, null: false
t.integer :answer_post_id, null: false
t.integer :accepter_user_id, null: false
t.integer :topic_timer_id
t.timestamps
end
end
end

View File

@ -1,19 +1,11 @@
# frozen_string_literal: true
#
class CopySolvedTopicCustomFieldToDiscourseSolvedTopics < ActiveRecord::Migration[7.2]
class CopySolvedTopicCustomFieldToDiscourseSolvedSolvedTopics < ActiveRecord::Migration[7.2]
disable_ddl_transaction!
BATCH_SIZE = 5000
def up
create_table :discourse_solved_solved_topics do |t|
t.integer :topic_id, null: false
t.integer :answer_post_id, null: false
t.integer :accepter_user_id, null: false
t.integer :topic_timer_id
t.timestamps
end
last_id = 0
loop do
rows = DB.query(<<~SQL, last_id: last_id, batch_size: BATCH_SIZE)