2018-08-14 17:19:32 +00:00
|
|
|
class CopyStatusStats < ActiveRecord::Migration[5.2]
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
safety_assured do
|
|
|
|
execute <<-SQL.squish
|
2018-08-14 18:24:36 +00:00
|
|
|
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
|
|
|
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
2018-08-14 17:19:32 +00:00
|
|
|
FROM statuses
|
|
|
|
ON CONFLICT (status_id) DO UPDATE
|
|
|
|
SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
|
|
|
SQL
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# Nothing
|
|
|
|
end
|
|
|
|
end
|