gearheads
/
mastodon
Archived
2
0
Fork 0
This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
mastodon/db/migrate/20180812173710_copy_status_...

20 lines
490 B
Ruby
Raw Normal View History

class CopyStatusStats < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
safety_assured do
execute <<-SQL.squish
INSERT INTO status_stats (status_id, reblogs_count, favourites_count)
SELECT id, reblogs_count, favourites_count
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