You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
538 B

  1. class CopyStatusStats < ActiveRecord::Migration[5.2]
  2. disable_ddl_transaction!
  3. def up
  4. safety_assured do
  5. execute <<-SQL.squish
  6. INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
  7. SELECT id, reblogs_count, favourites_count, created_at, updated_at
  8. FROM statuses
  9. ON CONFLICT (status_id) DO UPDATE
  10. SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
  11. SQL
  12. end
  13. end
  14. def down
  15. # Nothing
  16. end
  17. end