The general advice is I should always test my database migrations, but how to do it seems to be a well kept secret ;)
My chosen framework is FluentMigration.
What I think I want to do is:
But I can't figure out how to run the migrations from my unit tests.
To kick off the migration in your integration tests just shell out to the migrate.exe command using Process.Start
For example
var migrator = System.Diagnostics.Process.Start("migrator.exe", "/connection \"Data Source=db\\db.sqlite;Version=3;\" /db sqlite /target your.migrations.dll");
migrator.WaitForExit();
If you're using MSTest you'll have to make sure that migrator.exe is included as a deployment item, or that you specify a path to where the .exe lives when you start the process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With