Split create and copy
This commit is contained in:
parent
8036f5b4b2
commit
7d6611def6
|
|
@ -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
|
||||||
|
|
@ -1,19 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
class CopySolvedTopicCustomFieldToDiscourseSolvedTopics < ActiveRecord::Migration[7.2]
|
class CopySolvedTopicCustomFieldToDiscourseSolvedSolvedTopics < ActiveRecord::Migration[7.2]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
BATCH_SIZE = 5000
|
BATCH_SIZE = 5000
|
||||||
|
|
||||||
def up
|
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
|
last_id = 0
|
||||||
loop do
|
loop do
|
||||||
rows = DB.query(<<~SQL, last_id: last_id, batch_size: BATCH_SIZE)
|
rows = DB.query(<<~SQL, last_id: last_id, batch_size: BATCH_SIZE)
|
||||||
Loading…
Reference in New Issue