Revert "Skip incompatible migration entirely"
This reverts commit 545eb6385d73efb004dd73535adc5279cd7b7a92.
This commit is contained in:
parent
545eb6385d
commit
ebdf94e346
@ -2,19 +2,18 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
|||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def up
|
def up
|
||||||
# FIXME upserts don't work in PostgreSQL 9.4, so we're skipping this for now.
|
safety_assured do
|
||||||
# safety_assured do
|
Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
||||||
# Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
execute <<-SQL.squish
|
||||||
# execute <<-SQL.squish
|
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
||||||
# INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
||||||
# SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
FROM statuses
|
||||||
# FROM statuses
|
WHERE id IN (#{statuses.map(&:id).join(', ')})
|
||||||
# WHERE id IN (#{statuses.map(&:id).join(', ')})
|
ON CONFLICT (status_id) DO UPDATE
|
||||||
# ON CONFLICT (status_id) DO UPDATE
|
SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
||||||
# SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
SQL
|
||||||
# SQL
|
end
|
||||||
# end
|
end
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
Loading…
x
Reference in New Issue
Block a user