1

I've glanced over the different documentation, though have not found anything that addresses this. I'm looking at using fluentmigrator for future projects, though for staging/production practices have to do schema updates through a dba. I am allowed to do what I want for other environments such as testing, dev and local.

The purpose of the tool is entirely defeated if I have to write the scripts to do the changes anyway. However, it occurred to me, what if I didn't? So my question is this: Is it possible to have fluent migrate spit out a sql script to a file, instead of actually running the transaction?

In my experimentation I created a console app that uses the same DAL assembly as the main project, and leverages the migrator logic, so that whenever I run the console app, it updates the db from scratch, or from the nearest point depending on my choice. We use TeamCity, so thought it could be cool to have it run the app and place the script ( as an artifact) in a folder as a step in the build process for our DBA in the environments updating the schema myself would be frowned upon.

2 Answers 2

4

The FluentMigrator Command Line Runner will generate SQL scripts, without applying the changes to the database, if you use:

  • --preview=true
  • --output=true
  • --outputFilename=output1.sql

And, if you install the FluentMigrator.Tools package in addition to the FluentMigrator package, you will have access to the Command Line Runner from the migration project's build output directory (Migrate.exe).

Note: The generated scripts will contain inserts into the FluentMigrator version table.

1
0

After reading Command Line Runner Options I'd use --verbose=true to output the sql script and --output to save it to a file. There seems to be no 'dry run' option however - you'll need to run the migration in some preproduction environment to obtain the script.

Give it a shot as I've admittedly never tried it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.