Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<PackageVersion Include="FastEndpoints.Swagger" Version="7.1.1"/>
<PackageVersion Include="FluentMigrator" Version="7.2.0"/>
<PackageVersion Include="FluentMigrator.Runner" Version="7.2.0"/>
<PackageVersion Include="FluentMigrator.Runner.Core" Version="7.2.0"/>
<PackageVersion Include="FluentMigrator.Runner.SqlServer" Version="7.2.0"/>
<PackageVersion Include="FluentMigrator.Runner.SQLite" Version="7.2.0"/>
<PackageVersion Include="FluentStorage" Version="6.0.0"/>
<PackageVersion Include="Fluid.Core" Version="2.31.0"/>
<PackageVersion Include="Fody" Version="6.9.3"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<PackageReference Include="Azure.Identity"/>
<PackageReference Include="Dapper"/>
<PackageReference Include="FluentMigrator"/>
<PackageReference Include="FluentMigrator.Runner"/>
<PackageReference Include="FluentMigrator.Runner.Core"/>
<PackageReference Include="Microsoft.Data.Sqlite.Core"/>
<PackageReference Include="Microsoft.Data.SqlClient"/>
<PackageReference Include="Microsoft.Identity.Client"/>
<PackageReference Include="Npgsql"/>
<PackageReference Include="System.Data.SqlClient"/>
<PackageReference Include="System.Formats.Asn1"/>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ namespace Elsa.Persistence.Dapper.Features;
public class DapperMigrationsFeature(IModule module) : FeatureBase(module)
{
/// <summary>
/// Configures migrations to use SQLite.
/// </summary>
public DapperMigrationsFeature UseSqlite()
{
ConfigureRunner += runner => runner.AddSQLite();
return this;
}

/// <summary>
/// Configures migrations to use SQLite.
/// </summary>
public DapperMigrationsFeature UseSqlServer()
{
ConfigureRunner += runner => runner.AddSqlServer();
return this;
}

/// <summary>
/// Gets or sets a delegate to configure migrations.
/// Gets or sets a delegate used to configure the <see cref="IMigrationRunnerBuilder"/> for Dapper migrations.
/// </summary>
/// <remarks>
/// The delegate must configure a database provider on the runner (for example by calling
/// <c>AddSqlServer()</c> or <c>AddSQLite()</c>) in addition to any other settings.
/// This replaces the removed <c>UseSqlServer()</c> and <c>UseSqlite()</c> convenience methods;
/// consumers migrating from those APIs should move their provider configuration into this delegate.
/// </remarks>
public Action<IMigrationRunnerBuilder> ConfigureRunner { get; set; } = runner => runner
.WithGlobalConnectionString(sp => sp.GetRequiredService<IDbConnectionProvider>().GetConnectionString())
.WithMigrationsIn(typeof(Initial).Assembly);
Expand Down
2 changes: 2 additions & 0 deletions src/workbench/Elsa.Server.Web/Elsa.Server.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<PackageReference Include="Elsa.Workflows.Api" />
<PackageReference Include="Elsa.WorkflowProviders.BlobStorage" />
<PackageReference Include="Elsa.Workflows.Runtime.Distributed" />
<PackageReference Include="FluentMigrator.Runner.SqlServer" />
<PackageReference Include="FluentMigrator.Runner.SQLite" />
<PackageReference Include="Hangfire.Core" />
<PackageReference Include="Hangfire.MemoryStorage" />
<PackageReference Include="Hangfire.PostgreSql" />
Expand Down
16 changes: 12 additions & 4 deletions src/workbench/Elsa.Server.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Elsa.Identity.Multitenancy;
using Elsa.OpenTelemetry.Middleware;
using Elsa.Persistence.Dapper.Extensions;
using Elsa.Persistence.Dapper.Contracts;
using Elsa.Persistence.Dapper.Services;
using Elsa.Persistence.EFCore.Extensions;
using Elsa.Persistence.EFCore.Modules.Alterations;
Expand Down Expand Up @@ -53,6 +54,7 @@
using Elsa.Workflows.Runtime.Options;
using Elsa.Workflows.Runtime.Stores;
using Elsa.Workflows.Runtime.Tasks;
using FluentMigrator.Runner;
using Hangfire;
using Hangfire.MemoryStorage;
using Hangfire.PostgreSql;
Expand Down Expand Up @@ -128,10 +130,16 @@
{
dapper.UseMigrations(feature =>
{
if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer)
feature.UseSqlServer();
else
feature.UseSqlite();
feature.ConfigureRunner = builder =>
{
var runnerBuilder = sqlDatabaseProvider == SqlDatabaseProvider.SqlServer
? builder.AddSqlServer()
: builder.AddSQLite();

runnerBuilder
.WithGlobalConnectionString(sp => sp.GetRequiredService<IDbConnectionProvider>().GetConnectionString())
.WithMigrationsIn(typeof(Elsa.Persistence.Dapper.Migrations.Management.Initial).Assembly);
};
});
dapper.DbConnectionProvider = sp =>
{
Expand Down
Loading