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.

22 lines
558 B

  1. # frozen_string_literal: true
  2. class MigrateNotificationsType < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. TYPES_TO_MIGRATE = {
  5. 'Mention' => :mention,
  6. 'Status' => :reblog,
  7. 'Follow' => :follow,
  8. 'FollowRequest' => :follow_request,
  9. 'Favourite' => :favourite,
  10. 'Poll' => :poll,
  11. }.freeze
  12. def up
  13. TYPES_TO_MIGRATE.each_pair do |activity_type, type|
  14. Notification.where(activity_type: activity_type, type: nil).in_batches.update_all(type: type)
  15. end
  16. end
  17. def down; end
  18. end