As a result of my previous post of FluentMigrator, i thought publishing a follow-up article would be a great idea. Meanwhile I joined the team of FluentMigrator as a contributor. I would like to continue on the previous post and show some more common scenario’s.
Let’s revisit the first migration we wrote, we where creating a unique index on email with a separate Create expression, with the latest bits, that is no longer necessary as the Unique() and Indexed() methods are now implemented for single column indexes.
Just for reference i will add the command prompt syntax for the last time
Important: we no longer define the -conn parameter, if we add a connection to the app.config of our migration assembly named the same as our machine name, it will automagically fall back to that one. Another recent addition.
Let’s add some data to it
We’ll use the embedded script just as a showcase for it because you could also make this work with an Insert expression.
We’ll also need an embedded sql script named: M0002_Data.sql
Remember that we could just rollback 1 step (1 migration) with following command (see Wiki)
Add PersonType table with data
Last but not least
Add a column and foreign key constraint from Person.PersonTypeId to PersonType.Id