notonthehighstreet/data_migrations — pull request #6 by andyw8 (2013-06-14 09:05:48+00:00)
Title: INTL-323 Site-specific migrations

CI: [Pending]
QA:

This PR introduces a mechanism to ensure that all data migrations specify which site they are targeted at (UK, DE or both). This is to reduce the risk of wrongly running a migration against the wrong site.

This only applies to data migrations, not schema migrations.

To specify which site a migration is targeting, use `for_site`:
```rb
class MyMigration < ActiveRecord::Migration
for_site :uk, :de
def up
...
end
end
```
If you try to run a data migration which doesn't specify a site, it will raise an `InvalidSiteMigration` error.

To allow developers to run older data migrations, which do not specify a site, there is a `SKIP_MIGRATION_SITE_CHECK` environment variable to override the check.

With credit to @ohthatjames for making sense of Rails' migration internals.