```ruby
class DeleteInProgressOrders < ActiveRecord::Migration
  def self.up
    Order.delete_all(:state=>'in_progress')
    delete_orphans('adjustments')
    delete_orphans('checkouts')
    delete_orphans('shipments')
    delete_orphans('payments')
    delete_orphans('line_items')
    delete_orphans('inventory_units')
  end

  def self.delete_orphans(table_name)
    execute("delete from #{table_name} where order_id not in (select id from orders)")
  end

  def self.down
  end
end```

Add legacy table support to delete in progress orders migration
user
```ruby
class DeleteInProgressOrders < ActiveRecord::Migration
  # legacy table support
  class Order < ActiveRecord::Base

  end
  def self.up
    Order.delete_all(:state=>'in_progress')
    delete_orphans('adjustments')
    delete_orphans('checkouts')
    delete_orphans('shipments')
    delete_orphans('payments')
    delete_orphans('line_items')
    delete_orphans('inventory_units')
  end

  def self.delete_orphans(table_name)
    execute("delete from #{table_name} where order_id not in (select id from orders)")
  end

  def self.down
  end
end```
assistant