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