```ruby
class AddSubscriptionReferenceToOrders < ActiveRecord::Migration[5.2]
  def change
    add_reference :spree_orders, :subscription, null: true, foreign_key: { to_table: :solidus_subscriptions_subscriptions }
  end
end
```

Use integer foreign keys for compatibility with old tables
user
```ruby
class AddSubscriptionReferenceToOrders < ActiveRecord::Migration[5.2]
  def change
    add_reference :spree_orders, :subscription, null: true, foreign_key: {
      to_table: :solidus_subscriptions_subscriptions,
      type: :integer,
    }
  end
end
```
assistant