FIX: move post_search_data migration into onceoff job (#11851)

And reduce the size of the batches to 100k.

That should hopefully make the migrations run smoother...
This commit is contained in:
Régis Hanol
2021-01-26 16:29:00 +01:00
committed by GitHub
parent 4228c7e7d1
commit cd3d24ed8c
2 changed files with 26 additions and 2 deletions
@@ -4,7 +4,7 @@ class MigrateSearchDataAfterDefaultLocaleRename < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
%w{category tag topic post user}.each { |model| fix_search_data(model) }
%w{category tag topic user}.each { |model| fix_search_data(model) }
end
def down
@@ -17,6 +17,8 @@ class MigrateSearchDataAfterDefaultLocaleRename < ActiveRecord::Migration[6.0]
key = "#{model}_id"
table = "#{model}_search_data"
puts "Migrating #{table} to new locale."
sql = <<~SQL
UPDATE #{table}
SET locale = 'en'
@@ -24,7 +26,7 @@ class MigrateSearchDataAfterDefaultLocaleRename < ActiveRecord::Migration[6.0]
SELECT #{key}
FROM #{table}
WHERE locale = 'en_US'
LIMIT 500000
LIMIT 100000
)
SQL