schambers/fluentmigrator — Issue #226: Filter migrations run based on Tags
Author: kieranmaine
Created: 2012-01-06 16:31:47+00:00
State: open

I have a situation where multiple database once had the same schema but over the years have had differences introduced.

Because of this the majority of migrations, contained in one assembly, can be run against all the databases but at the same time I need to be able to filter certain migrations to run against specific databases based on the country (UK, DK, etc) and environment (Staging, Production, etc) it serves.

To facilitate this I propose adding the ability to tag migrations (much like cucumber scenarios) and then filter these by passing tags into the runner (via the Console, MSBuild or Nant). A migration is then run if it has:

* No Tags
* OR Has Tags that match ALL those passed into the runner.

Tags would be assigned to migrations with an attribute/s:

```c#
[Tag("DK", "NL", "UK")]
[Tag("Staging", "Production")]
[Migration(1)]
public class DoSomeStuffToEuropeanStagingAndProdDbs() { }
```

And the tags would be entered into the command line like so: (Migrations with UK AND Production tags executed)

```
--tags UK --tags Production
```