Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Name editable in V3 #4072

Merged
merged 10 commits into from
May 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaMySql(this DbContextOptionsBuilder builder, string connectionString, Action<MySqlDbContextOptionsBuilder>? configure = default) =>
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db =>
public static DbContextOptionsBuilder UseElsaMySql(this DbContextOptionsBuilder builder, string connectionString,ElsaDbContextOptions? options = default, Action<MySqlDbContextOptionsBuilder>? configure = default) =>
builder
.UseElsaDbContextOptions(options)
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema)
.MigrationsAssembly(options?.MigrationsAssemblyName ?? typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(options?.MigrationsHistoryTableName ?? ElsaDbContextBase.MigrationsHistoryTable, options?.SchemaName ?? ElsaDbContextBase.ElsaSchema)
.SchemaBehavior(MySqlSchemaBehavior.Ignore);

configure?.Invoke(db);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Common;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
Expand All @@ -10,10 +11,11 @@ public static partial class Extensions
/// </summary>
/// <param name="feature">The feature to configure.</param>
/// <param name="connectionString">The connection string to use.</param>
/// <param name="options">Options specified via <see cref="ElsaDbContextOptions"/> allows to configure for manual database migrations.</param>
/// <returns>The configured feature.</returns>
public static EFCoreIdentityPersistenceFeature UseMySql(this EFCoreIdentityPersistenceFeature feature, string connectionString)
public static EFCoreIdentityPersistenceFeature UseMySql(this EFCoreIdentityPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.Common;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreLabelPersistenceFeature UseMySql(this EFCoreLabelPersistenceFeature feature, string connectionString)
public static EFCoreLabelPersistenceFeature UseMySql(this EFCoreLabelPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Common;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
Expand All @@ -10,21 +11,21 @@ namespace Elsa.EntityFrameworkCore.Extensions;
[PublicAPI]
public static partial class Extensions
{
public static EFCoreWorkflowDefinitionPersistenceFeature UseMySql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowDefinitionPersistenceFeature UseMySql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}

public static EFCoreWorkflowInstancePersistenceFeature UseMySql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString)
public static EFCoreWorkflowInstancePersistenceFeature UseMySql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}

public static EFCoreWorkflowManagementPersistenceFeature UseMySql(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowManagementPersistenceFeature UseMySql(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.EntityFrameworkCore.Common;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreDefaultWorkflowRuntimePersistenceFeature UseMySql(this EFCoreDefaultWorkflowRuntimePersistenceFeature feature, string connectionString)
public static EFCoreDefaultWorkflowRuntimePersistenceFeature UseMySql(this EFCoreDefaultWorkflowRuntimePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}

public static EFCoreExecutionLogRecordPersistenceFeature UseMySql(this EFCoreExecutionLogRecordPersistenceFeature feature, string connectionString)
public static EFCoreExecutionLogRecordPersistenceFeature UseMySql(this EFCoreExecutionLogRecordPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaPostgreSql(this DbContextOptionsBuilder builder, string connectionString, Action<NpgsqlDbContextOptionsBuilder>? configure = default) =>
builder.UseNpgsql(connectionString, db =>
public static DbContextOptionsBuilder UseElsaPostgreSql(this DbContextOptionsBuilder builder, string connectionString,ElsaDbContextOptions? options = default, Action<NpgsqlDbContextOptionsBuilder>? configure = default) =>
builder
.UseElsaDbContextOptions(options)
.UseNpgsql(connectionString, db =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema);
.MigrationsAssembly(options?.MigrationsAssemblyName ?? typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(options?.MigrationsHistoryTableName ?? ElsaDbContextBase.MigrationsHistoryTable, options?.SchemaName ?? ElsaDbContextBase.ElsaSchema);

configure?.Invoke(db);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Identity;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
Expand All @@ -10,10 +11,11 @@ public static partial class Extensions
/// </summary>
/// <param name="feature">The feature to configure.</param>
/// <param name="connectionString">The connection string to use.</param>
/// <param name="options">Options specified via <see cref="ElsaDbContextOptions"/> allows to configure for manual database migrations.</param>
/// <returns>The configured feature.</returns>
public static EFCoreIdentityPersistenceFeature UsePostgreSql(this EFCoreIdentityPersistenceFeature feature, string connectionString)
public static EFCoreIdentityPersistenceFeature UsePostgreSql(this EFCoreIdentityPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Labels;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreLabelPersistenceFeature UsePostgreSql(this EFCoreLabelPersistenceFeature feature, string connectionString)
public static EFCoreLabelPersistenceFeature UsePostgreSql(this EFCoreLabelPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Management;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
Expand All @@ -10,21 +11,21 @@ namespace Elsa.EntityFrameworkCore.Extensions;
[PublicAPI]
public static partial class Extensions
{
public static EFCoreWorkflowDefinitionPersistenceFeature UsePostgreSql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowDefinitionPersistenceFeature UsePostgreSql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}

public static EFCoreWorkflowInstancePersistenceFeature UsePostgreSql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString)
public static EFCoreWorkflowInstancePersistenceFeature UsePostgreSql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}

public static EFCoreWorkflowManagementPersistenceFeature UsePostgreSql(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowManagementPersistenceFeature UsePostgreSql(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Runtime;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreDefaultWorkflowRuntimePersistenceFeature UsePostgreSql(this EFCoreDefaultWorkflowRuntimePersistenceFeature feature, string connectionString)
public static EFCoreDefaultWorkflowRuntimePersistenceFeature UsePostgreSql(this EFCoreDefaultWorkflowRuntimePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}

public static EFCoreExecutionLogRecordPersistenceFeature UsePostgreSql(this EFCoreExecutionLogRecordPersistenceFeature feature, string connectionString)
public static EFCoreExecutionLogRecordPersistenceFeature UsePostgreSql(this EFCoreExecutionLogRecordPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaSqlServer(this DbContextOptionsBuilder builder, string connectionString, Action<SqlServerDbContextOptionsBuilder>? configure = default) =>
builder.UseSqlServer(connectionString, db =>
public static DbContextOptionsBuilder UseElsaSqlServer(this DbContextOptionsBuilder builder, string connectionString, ElsaDbContextOptions? options = default, Action<SqlServerDbContextOptionsBuilder>? configure = default) =>
builder
.UseElsaDbContextOptions(options)
.UseSqlServer(connectionString, db =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema);
.MigrationsAssembly(options?.MigrationsAssemblyName ?? typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(options?.MigrationsHistoryTableName ?? ElsaDbContextBase.MigrationsHistoryTable, options?.SchemaName ?? ElsaDbContextBase.ElsaSchema);

configure?.Invoke(db);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Identity;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
Expand All @@ -13,10 +14,11 @@ public static partial class Extensions
/// </summary>
/// <param name="feature">The feature to configure.</param>
/// <param name="connectionString">The connection string to use.</param>
/// <param name="options">Options specified via <see cref="ElsaDbContextOptions"/> allows to configure for manual database migrations.</param>
/// <returns>The configured feature.</returns>
public static EFCoreIdentityPersistenceFeature UseSqlServer(this EFCoreIdentityPersistenceFeature feature, string connectionString)
public static EFCoreIdentityPersistenceFeature UseSqlServer(this EFCoreIdentityPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Labels;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreLabelPersistenceFeature UseSqlServer(this EFCoreLabelPersistenceFeature feature, string connectionString)
public static EFCoreLabelPersistenceFeature UseSqlServer(this EFCoreLabelPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString, options);
return feature;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Management;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
Expand All @@ -7,21 +8,21 @@ namespace Elsa.EntityFrameworkCore.Extensions;
[PublicAPI]
public static partial class Extensions
{
public static EFCoreWorkflowDefinitionPersistenceFeature UseSqlServer(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowDefinitionPersistenceFeature UseSqlServer(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString, options);
return feature;
}

public static EFCoreWorkflowInstancePersistenceFeature UseSqlServer(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString)
public static EFCoreWorkflowInstancePersistenceFeature UseSqlServer(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString, options);
return feature;
}

public static EFCoreWorkflowManagementPersistenceFeature UseSqlServer(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString)
public static EFCoreWorkflowManagementPersistenceFeature UseSqlServer(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString, options);
return feature;
}
}
Loading