Fluentmigrator: How to Generate SQL Script Migrations using In-Process Runner?

Created on 6 Oct 2019  路  3Comments  路  Source: fluentmigrator/fluentmigrator

Is there a way to generate SQL file output using the In-Process Migration Runner similarly to what can be achieved using -output command argument from the dotnet-fm tool.

I couldn't find any property, field or method in the IMigrationRunner, IMigrationRunnerBuilder or in the IMigrationProcessorOptions that would set configure the output.

Am I missing something?

area-runner-InProcessRunner question question-answered

Most helpful comment

Hi @RaulSebastian ,

The "sample" on how to do this is probably best taken from the dotnet-fm tool itself - the dotnet-fm tool is simply the "default" In-Process Runner mapped into a .NET Command Line Tool. See /src/FluentMigrator.DotNet.Cli/Setup.cs (in Visual Studio Solution Explorer, this is under src/runners/FkuentMigrator.DotNet.Cli/Setup.cs) - I'm sorry this isn't intuitively obvious where to look. We would be happy to accept a PR to improve the documentation and samples, though!

c# if (options.Output) { services .AddSingleton<ILoggerProvider, LogFileFluentMigratorLoggerProvider>() .Configure<LogFileFluentMigratorLoggerOptions>( opt => { opt.OutputFileName = options.OutputFileName; opt.OutputGoBetweenStatements = targetIsSqlServer; opt.ShowSql = true; }); }

All 3 comments

Hi @RaulSebastian ,

The "sample" on how to do this is probably best taken from the dotnet-fm tool itself - the dotnet-fm tool is simply the "default" In-Process Runner mapped into a .NET Command Line Tool. See /src/FluentMigrator.DotNet.Cli/Setup.cs (in Visual Studio Solution Explorer, this is under src/runners/FkuentMigrator.DotNet.Cli/Setup.cs) - I'm sorry this isn't intuitively obvious where to look. We would be happy to accept a PR to improve the documentation and samples, though!

c# if (options.Output) { services .AddSingleton<ILoggerProvider, LogFileFluentMigratorLoggerProvider>() .Configure<LogFileFluentMigratorLoggerOptions>( opt => { opt.OutputFileName = options.OutputFileName; opt.OutputGoBetweenStatements = targetIsSqlServer; opt.ShowSql = true; }); }

Is there a way to ONLY generate the SQL and not execute it though?

I can disconnect it from the database but then it generates the SQL for the 1st migration only, ending on a "ROLLBACK TRANSACTION"

Disregard the noob, found it, AsGlobalPreview is the thing I need.

Was this page helpful?
0 / 5 - 0 ratings