20201017234926_fill_account_suspension_origin.rb 525 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class FillAccountSuspensionOrigin < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. class MigrationAccount < ApplicationRecord
  5. self.table_name = :accounts
  6. scope :suspended, -> { where.not(suspended_at: nil) }
  7. enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
  8. end
  9. def up
  10. MigrationAccount.reset_column_information
  11. MigrationAccount.suspended.where(suspension_origin: nil).in_batches.update_all(suspension_origin: :local)
  12. end
  13. def down; end
  14. end