```ruby
class EnsurePaymentsHaveNumbers < ActiveRecord::Migration
  def change
    Spree::Payment.where(number: nil).find_each do |payment|
      payment.generate_number
      payment.save
    end
  end
end
```

Update only the payment's number during migration.
user
```ruby
class EnsurePaymentsHaveNumbers < ActiveRecord::Migration
  def change
    Spree::Payment.where(number: nil).find_each do |payment|
      payment.generate_number
      payment.update_columns(number: payment.number)
    end
  end
end
```
assistant