foodsoft/db/migrate/20181204000000_clear_invalid_invoices_from_orders.rb
2021-03-02 09:12:19 +01:00

9 lines
244 B
Ruby

class ClearInvalidInvoicesFromOrders < ActiveRecord::Migration[4.2]
class Order < ActiveRecord::Base; end
class Invoice < ActiveRecord::Base; end
def up
Order.where.not(invoice_id: Invoice.all).update_all(invoice_id: nil)
end
end