-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDapperMigrationsFeature.cs
More file actions
37 lines (34 loc) · 1.51 KB
/
DapperMigrationsFeature.cs
File metadata and controls
37 lines (34 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Elsa.Persistence.Dapper.Contracts;
using Elsa.Persistence.Dapper.HostedServices;
using Elsa.Persistence.Dapper.Migrations.Management;
using Elsa.Extensions;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using FluentMigrator.Runner;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.Dapper.Features;
/// <summary>
/// Configures migrations.
/// </summary>
public class DapperMigrationsFeature(IModule module) : FeatureBase(module)
{
/// <summary>
/// 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);
/// <inheritdoc />
public override void Configure()
{
Services.AddFluentMigratorCore();
Services.ConfigureRunner(ConfigureRunner);
Services.AddStartupTask<RunMigrationsStartupTask>();
}
}