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!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def up
|
def up
|
||||||
safety_assured do
|
# FIXME upserts don't work in PostgreSQL 9.4, so we're skipping this for now.
|
||||||
Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
# safety_assured do
|
||||||
execute <<-SQL.squish
|
# Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
||||||
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
# execute <<-SQL.squish
|
||||||
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
# INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
||||||
FROM statuses
|
# SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
||||||
WHERE id IN (#{statuses.map(&:id).join(', ')})
|
# FROM statuses
|
||||||
ON CONFLICT (status_id) DO UPDATE
|
# WHERE id IN (#{statuses.map(&:id).join(', ')})
|
||||||
SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
# ON CONFLICT (status_id) DO UPDATE
|
||||||
SQL
|
# SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
||||||
end
|
# SQL
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
Loading…
x
Reference in New Issue
Block a user