Fix Oracle migrations

This commit is contained in:
Sipke Schoorstra 2025-02-01 00:38:38 +01:00
parent 6c0d1ea66c
commit 2bb3af1e5d
36 changed files with 302 additions and 242 deletions

View file

@ -0,0 +1,37 @@
namespace Elsa.Extensions;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds the service with a specific implementation type only if the combination
/// of service and implementation does not already exist in the service collection.
/// </summary>
public static IServiceCollection TryAddScopedImplementation<TService, TImplementation>(
this IServiceCollection services)
where TService : class
where TImplementation : class, TService
{
if (!services.Any(sd => sd.ServiceType == typeof(TService) && sd.ImplementationType == typeof(TImplementation)))
services.AddScoped<TService, TImplementation>();
return services;
}
/// <summary>
/// Adds the service with a specific implementation factory only if the combination
/// of service and implementation already doesn't exist.
/// </summary>
public static IServiceCollection TryAddScopedImplementation<TService>(
this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)
where TService : class
{
if (services.All(sd => sd.ServiceType != typeof(TService)))
services.AddScoped(implementationFactory);
return services;
}
}

View file

@ -18,7 +18,8 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
EntityState.Modified,
};
protected readonly IServiceProvider ServiceProvider;
protected IServiceProvider ServiceProvider { get; }
private readonly ElsaDbContextOptions? _elsaDbContextOptions;
public string? TenantId { get; set; }
/// <summary>
@ -40,10 +41,10 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
protected ElsaDbContextBase(DbContextOptions options, IServiceProvider serviceProvider) : base(options)
{
ServiceProvider = serviceProvider;
var elsaDbContextOptions = options.FindExtension<ElsaDbContextOptionsExtension>()?.Options;
_elsaDbContextOptions = options.FindExtension<ElsaDbContextOptionsExtension>()?.Options;
// ReSharper disable once VirtualMemberCallInConstructor
Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;
Schema = !string.IsNullOrWhiteSpace(_elsaDbContextOptions?.SchemaName) ? _elsaDbContextOptions.SchemaName : ElsaSchema;
var tenantAccessor = serviceProvider.GetService<ITenantAccessor>();
var tenantId = tenantAccessor?.Tenant?.Id;
@ -70,19 +71,19 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (!string.IsNullOrWhiteSpace(Schema))
{
if (!string.IsNullOrWhiteSpace(Schema))
modelBuilder.HasDefaultSchema(Schema);
}
var additionalConfigurations = _elsaDbContextOptions?.GetModelConfigurations(this);
additionalConfigurations?.Invoke(modelBuilder);
var entityTypeHandlers = ServiceProvider.GetServices<IEntityModelCreatingHandler>().ToList();
foreach (var entityType in modelBuilder.Model.GetEntityTypes().ToList())
{
foreach (var handler in entityTypeHandlers)
{
foreach (var handler in entityTypeHandlers)
handler.Handle(this, modelBuilder, entityType);
}
}
}

View file

@ -1,4 +1,5 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
namespace Elsa.EntityFrameworkCore;
@ -22,4 +23,30 @@ public class ElsaDbContextOptions
/// The assembly name containing the migrations.
/// </summary>
public string? MigrationsAssemblyName { get; set; }
public IDictionary<Type, Action<ModelBuilder>> ProviderSpecificConfigurations { get; set; } = new Dictionary<Type, Action<ModelBuilder>>();
public void ConfigureModel<TDbContext>(Action<ModelBuilder> configure) where TDbContext : DbContext
{
ConfigureModel(typeof(TDbContext), configure);
}
public void ConfigureModel(Type dbContextType, Action<ModelBuilder> configure)
{
if (!ProviderSpecificConfigurations.TryGetValue(dbContextType, out var configurations))
ProviderSpecificConfigurations[dbContextType] = configurations = _ => { };
configurations += configure;
ProviderSpecificConfigurations[dbContextType] = configurations;
}
public Action<ModelBuilder> GetModelConfigurations(DbContext dbContext)
{
return GetModelConfigurations(dbContext.GetType());
}
public Action<ModelBuilder> GetModelConfigurations(Type dbContextType)
{
return ProviderSpecificConfigurations.TryGetValue(dbContextType, out var providerConfigurations) ? providerConfigurations : _ => { };
}
}

View file

@ -16,7 +16,7 @@ public class RunMigrationsStartupTask<TDbContext>(IDbContextFactory<TDbContext>
/// <inheritdoc /
public async Task ExecuteAsync(CancellationToken cancellationToken)
{
var tenantDbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
await tenantDbContext.Database.MigrateAsync(cancellationToken);
var dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
await dbContext.Database.MigrateAsync(cancellationToken);
}
}

View file

@ -0,0 +1,26 @@
using Elsa.Workflows.Management.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Elsa.EntityFrameworkCore.Oracle.Configurations;
internal class Management : IEntityTypeConfiguration<WorkflowDefinition>, IEntityTypeConfiguration<WorkflowInstance>
{
public void Configure(EntityTypeBuilder<WorkflowDefinition> builder)
{
// In order to use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Property<string>("StringData").HasColumnType("NCLOB");
builder.Property<string>("Data").HasColumnType("NCLOB");
builder.Property(x => x.Description).HasColumnType("NCLOB");
builder.Property(x => x.MaterializerContext).HasColumnType("NCLOB");
builder.Property(x => x.BinaryData).HasColumnType("BLOB");
}
public void Configure(EntityTypeBuilder<WorkflowInstance> builder)
{
// In order to use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Property<string>("Data").HasColumnType("NCLOB");
}
}

View file

@ -0,0 +1,63 @@
using Elsa.Workflows.Runtime.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Elsa.EntityFrameworkCore.Oracle.Configurations;
public class Runtime :
IEntityTypeConfiguration<StoredTrigger>,
IEntityTypeConfiguration<WorkflowExecutionLogRecord>,
IEntityTypeConfiguration<ActivityExecutionRecord>,
IEntityTypeConfiguration<StoredBookmark>,
IEntityTypeConfiguration<WorkflowInboxMessage>
{
/// <inheritdoc />
public void Configure(EntityTypeBuilder<ActivityExecutionRecord> builder)
{
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Property<string>("SerializedActivityState").HasColumnType("NCLOB");
builder.Property<string>("SerializedException").HasColumnType("NCLOB");
builder.Property<string>("SerializedPayload").HasColumnType("NCLOB");
builder.Property<string>("SerializedOutputs").HasColumnType("NCLOB");
builder.Property<string>("SerializedProperties").HasColumnType("NCLOB");
}
/// <inheritdoc />
public void Configure(EntityTypeBuilder<StoredBookmark> builder)
{
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
// modelBuilder.Entity<StoredBookmark>().Ignore(x => x.Payload);
// modelBuilder.Entity<StoredBookmark>().Ignore(x => x.Metadata);
builder.Property<string>("SerializedPayload").HasColumnType("NCLOB");
builder.Property<string>("SerializedMetadata").HasColumnType("NCLOB");
}
/// <inheritdoc />
public void Configure(EntityTypeBuilder<StoredTrigger> builder)
{
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Property<string>("SerializedPayload").HasColumnType("NCLOB");
}
/// <inheritdoc />
public void Configure(EntityTypeBuilder<WorkflowExecutionLogRecord> builder)
{
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Property<string>("SerializedActivityState").HasColumnType("NCLOB");
builder.Property<string>("SerializedPayload").HasColumnType("NCLOB");
}
public void Configure(EntityTypeBuilder<WorkflowInboxMessage> builder)
{
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
builder.Ignore(x => x.Input);
builder.Ignore(x => x.BookmarkPayload);
builder.Property<string>("SerializedInput").HasColumnType("NCLOB");
builder.Property<string>("SerializedBookmarkPayload").HasColumnType("NCLOB");
}
}

View file

@ -35,6 +35,7 @@ public class OracleDesignTimeDbContextFactory<TDbContext> : DesignTimeDbContextF
{
protected override void ConfigureBuilder(DbContextOptionsBuilder<TDbContext> builder, string connectionString)
{
builder.UseElsaOracle(GetType().Assembly, connectionString);
var options = new ElsaDbContextOptions().Configure();
builder.UseElsaOracle(GetType().Assembly, connectionString, options);
}
}

View file

@ -13,7 +13,7 @@ public static class DbContextOptionsBuilderExtensions
/// <summary>
/// Configures Entity Framework Core with Oracle.
/// </summary>
public static DbContextOptionsBuilder UseElsaOracle(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = default, Action<OracleDbContextOptionsBuilder>? configure = default) =>
public static DbContextOptionsBuilder UseElsaOracle(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = null, Action<OracleDbContextOptionsBuilder>? configure = null) =>
builder
.UseElsaDbContextOptions(options)
.UseOracle(connectionString, db =>

View file

@ -20,5 +20,12 @@
<ItemGroup>
<PackageReference Include="System.Formats.Asn1" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Migrations\Management\20250131185451_V3_3_2.cs" />
<Compile Remove="Migrations\Management\20250131185451_V3_3_2.Designer.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View file

@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations
{
[DbContext(typeof(AlterationsElsaDbContext))]
[Migration("20241212211620_V3_3")]
[Migration("20250131233442_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity
{
[DbContext(typeof(IdentityElsaDbContext))]
[Migration("20241212211936_V3_3")]
[Migration("20250131233455_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -19,7 +19,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: _schema.Schema);
_schema.Schema);
migrationBuilder.CreateTable(
name: "Applications",

View file

@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels
{
[DbContext(typeof(LabelsElsaDbContext))]
[Migration("20241212212100_V3_3")]
[Migration("20250131233459_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -19,7 +19,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: _schema.Schema);
_schema.Schema);
migrationBuilder.CreateTable(
name: "Labels",

View file

@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
[Migration("20241212211817_V3_3")]
[Migration("20250131233451_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -32,35 +32,35 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(450)");
b.Property<byte[]>("BinaryData")
.HasColumnType("RAW(2000)");
.HasColumnType("BLOB");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
b.Property<string>("Data")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("Description")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<bool>("IsLatest")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsReadonly")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsSystem")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<string>("MaterializerContext")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("MaterializerName")
.IsRequired()
@ -73,7 +73,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(2000)");
b.Property<string>("StringData")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -82,7 +82,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(2000)");
b.Property<bool?>("UsableAsActivity")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<int>("Version")
.HasColumnType("NUMBER(10)");
@ -129,7 +129,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
b.Property<string>("Data")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("DataCompressionAlgorithm")
.HasColumnType("NVARCHAR2(2000)");
@ -149,7 +149,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NUMBER(10)");
b.Property<bool>("IsSystem")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<string>("Name")
.HasColumnType("NVARCHAR2(450)");

View file

@ -30,22 +30,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
Id = table.Column<string>(type: "NVARCHAR2(450)", nullable: false),
DefinitionId = table.Column<string>(type: "NVARCHAR2(450)", nullable: false),
Name = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
Description = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
Description = table.Column<string>(type: "NCLOB", nullable: true),
ToolVersion = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
ProviderName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
MaterializerName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false),
MaterializerContext = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
StringData = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
BinaryData = table.Column<byte[]>(type: "RAW(2000)", nullable: true),
IsReadonly = table.Column<bool>(type: "NUMBER(1)", nullable: false),
IsSystem = table.Column<bool>(type: "NUMBER(1)", nullable: false),
Data = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
UsableAsActivity = table.Column<bool>(type: "NUMBER(1)", nullable: true),
MaterializerContext = table.Column<string>(type: "NCLOB", nullable: true),
StringData = table.Column<string>(type: "NCLOB", nullable: true),
BinaryData = table.Column<byte[]>(type: "BLOB", nullable: true),
IsReadonly = table.Column<bool>(type: "BOOLEAN", nullable: false),
IsSystem = table.Column<bool>(type: "BOOLEAN", nullable: false),
Data = table.Column<string>(type: "NCLOB", nullable: true),
UsableAsActivity = table.Column<bool>(type: "BOOLEAN", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
Version = table.Column<int>(type: "NUMBER(10)", nullable: false),
IsLatest = table.Column<bool>(type: "NUMBER(1)", nullable: false),
IsPublished = table.Column<bool>(type: "NUMBER(1)", nullable: false)
IsLatest = table.Column<bool>(type: "BOOLEAN", nullable: false),
IsPublished = table.Column<bool>(type: "BOOLEAN", nullable: false)
},
constraints: table =>
{
@ -67,11 +67,11 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
CorrelationId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
Name = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
IncidentCount = table.Column<int>(type: "NUMBER(10)", nullable: false),
IsSystem = table.Column<bool>(type: "NUMBER(1)", nullable: false),
IsSystem = table.Column<bool>(type: "BOOLEAN", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
FinishedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: true),
Data = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
Data = table.Column<string>(type: "NCLOB", nullable: true),
DataCompressionAlgorithm = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true)
},

View file

@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -29,35 +29,35 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(450)");
b.Property<byte[]>("BinaryData")
.HasColumnType("RAW(2000)");
.HasColumnType("BLOB");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
b.Property<string>("Data")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("Description")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<bool>("IsLatest")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsReadonly")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<bool>("IsSystem")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<string>("MaterializerContext")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("MaterializerName")
.IsRequired()
@ -70,7 +70,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(2000)");
b.Property<string>("StringData")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -79,7 +79,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NVARCHAR2(2000)");
b.Property<bool?>("UsableAsActivity")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<int>("Version")
.HasColumnType("NUMBER(10)");
@ -126,7 +126,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
b.Property<string>("Data")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("DataCompressionAlgorithm")
.HasColumnType("NVARCHAR2(2000)");
@ -146,7 +146,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management
.HasColumnType("NUMBER(10)");
b.Property<bool>("IsSystem")
.HasColumnType("NUMBER(1)");
.HasColumnType("BOOLEAN");
b.Property<string>("Name")
.HasColumnType("NVARCHAR2(450)");

View file

@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
[Migration("20250116193207_V3_3")]
[Migration("20250131233446_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -75,22 +75,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("BOOLEAN");
b.Property<string>("SerializedActivityState")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedActivityStateCompressionAlgorithm")
.HasColumnType("NVARCHAR2(2000)");
b.Property<string>("SerializedException")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedOutputs")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedProperties")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<DateTimeOffset>("StartedAt")
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
@ -223,10 +223,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedMetadata")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -273,7 +273,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -346,10 +346,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NUMBER(19)");
b.Property<string>("SerializedActivityState")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("Source")
.HasColumnType("NVARCHAR2(2000)");
@ -457,10 +457,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedBookmarkPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedInput")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(2000)");

View file

@ -38,12 +38,12 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
HasBookmarks = table.Column<bool>(type: "BOOLEAN", nullable: false),
Status = table.Column<string>(type: "NVARCHAR2(450)", nullable: false),
CompletedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: true),
SerializedActivityState = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedActivityState = table.Column<string>(type: "NCLOB", nullable: true),
SerializedActivityStateCompressionAlgorithm = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedException = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedOutputs = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedPayload = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedProperties = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedException = table.Column<string>(type: "NCLOB", nullable: true),
SerializedOutputs = table.Column<string>(type: "NCLOB", nullable: true),
SerializedPayload = table.Column<string>(type: "NCLOB", nullable: true),
SerializedProperties = table.Column<string>(type: "NCLOB", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true)
},
constraints: table =>
@ -84,8 +84,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
ActivityInstanceId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
CorrelationId = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
SerializedMetadata = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedPayload = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedMetadata = table.Column<string>(type: "NCLOB", nullable: true),
SerializedPayload = table.Column<string>(type: "NCLOB", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true)
},
constraints: table =>
@ -118,7 +118,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
Name = table.Column<string>(type: "NVARCHAR2(450)", nullable: false),
ActivityId = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false),
Hash = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
SerializedPayload = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedPayload = table.Column<string>(type: "NCLOB", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true)
},
constraints: table =>
@ -148,8 +148,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
EventName = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
Message = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
Source = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedActivityState = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedPayload = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedActivityState = table.Column<string>(type: "NCLOB", nullable: true),
SerializedPayload = table.Column<string>(type: "NCLOB", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true)
},
constraints: table =>
@ -170,8 +170,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
ActivityInstanceId = table.Column<string>(type: "NVARCHAR2(450)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
ExpiresAt = table.Column<DateTimeOffset>(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false),
SerializedBookmarkPayload = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedInput = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true),
SerializedBookmarkPayload = table.Column<string>(type: "NCLOB", nullable: true),
SerializedInput = table.Column<string>(type: "NCLOB", nullable: true),
TenantId = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true)
},
constraints: table =>

View file

@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -72,22 +72,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("BOOLEAN");
b.Property<string>("SerializedActivityState")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedActivityStateCompressionAlgorithm")
.HasColumnType("NVARCHAR2(2000)");
b.Property<string>("SerializedException")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedOutputs")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedProperties")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<DateTimeOffset>("StartedAt")
.HasColumnType("TIMESTAMP(7) WITH TIME ZONE");
@ -220,10 +220,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedMetadata")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -270,7 +270,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(450)");
@ -343,10 +343,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NUMBER(19)");
b.Property<string>("SerializedActivityState")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("Source")
.HasColumnType("NVARCHAR2(2000)");
@ -454,10 +454,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime
.HasColumnType("NVARCHAR2(450)");
b.Property<string>("SerializedBookmarkPayload")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("SerializedInput")
.HasColumnType("NVARCHAR2(2000)");
.HasColumnType("NCLOB");
b.Property<string>("TenantId")
.HasColumnType("NVARCHAR2(2000)");

View file

@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants
{
[DbContext(typeof(TenantsElsaDbContext))]
[Migration("20241212212227_V3_3")]
[Migration("20250131233503_V3_3")]
partial class V3_3
{
/// <inheritdoc />
@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.20")
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);

View file

@ -1,10 +1,10 @@
using System.Reflection;
using Elsa.EntityFrameworkCore.Modules.Alterations;
using Elsa.EntityFrameworkCore.Oracle;
using Elsa.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.EntityFrameworkCore.Oracle.Configurations;
using Elsa.Workflows.Management.Entities;
using Elsa.Workflows.Runtime.Entities;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Oracle.EntityFrameworkCore.Infrastructure;
// ReSharper disable once CheckNamespace
@ -60,11 +60,28 @@ public static class OracleProvidersExtensions
where TDbContext : ElsaDbContextBase
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
{
feature.Services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForAlterations>();
feature.Services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForManagement>();
feature.Services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForRuntime>();
options ??= new();
options.Configure();
feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaOracle(migrationsAssembly, connectionStringFunc(sp), options, configure: configure);
return (TFeature)feature;
}
public static ElsaDbContextOptions Configure(this ElsaDbContextOptions options)
{
var management = new Management();
var runtime = new Runtime();
options.ConfigureModel<ManagementElsaDbContext>(modelBuilder => modelBuilder
.ApplyConfiguration<WorkflowDefinition>(management)
.ApplyConfiguration<WorkflowInstance>(management));
options.ConfigureModel<RuntimeElsaDbContext>(modelBuilder => modelBuilder
.ApplyConfiguration<StoredTrigger>(runtime)
.ApplyConfiguration<WorkflowExecutionLogRecord>(runtime)
.ApplyConfiguration<ActivityExecutionRecord>(runtime)
.ApplyConfiguration<StoredBookmark>(runtime)
.ApplyConfiguration<WorkflowInboxMessage>(runtime));
return options;
}
}

View file

@ -1,27 +0,0 @@
using Elsa.Alterations.Core.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle;
/// <summary>
/// Represents a class that handles entity model creation for SQLite databases.
/// </summary>
public class SetupForAlterations : IEntityModelCreatingHandler
{
/// <inheritdoc />
public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType)
{
if(!dbContext.Database.IsOracle())
return;
// In order to use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
modelBuilder.Entity<AlterationPlan>().Ignore(x => x.Alterations);
modelBuilder.Entity<AlterationPlan>().Ignore(x => x.WorkflowInstanceFilter);
modelBuilder.Entity<AlterationPlan>().Property<string>("SerializedAlterations").HasColumnType("NCLOB");
modelBuilder.Entity<AlterationPlan>().Property<string>("SerializedWorkflowInstanceFilter").HasColumnType("NCLOB");
modelBuilder.Entity<AlterationJob>().Ignore(x => x.Log);
modelBuilder.Entity<AlterationJob>().Property<string>("SerializedLog").HasColumnType("NCLOB");
}
}

View file

@ -1,39 +0,0 @@
using System.Linq.Expressions;
using Elsa.Workflows.Management.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle;
/// <summary>
/// Represents a class that handles entity model creation for SQLite databases.
/// </summary>
public class SetupForManagement : IEntityModelCreatingHandler
{
private static Expression<Func<Version?, string?>> VersionToStringConverter => v => v != null ? v.ToString() : null;
private static Expression<Func<string?, Version?>> StringToVersionConverter => v => v != null ? Version.Parse(v) : null;
/// <inheritdoc />
public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType)
{
if(!dbContext.Database.IsOracle())
return;
// In order to use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
modelBuilder.Entity<WorkflowInstance>().Property<string>("Data").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowInstance>().Ignore(x => x.WorkflowState);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.CustomProperties);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.Variables);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.Inputs);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.Outputs);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.Outcomes);
modelBuilder.Entity<WorkflowDefinition>().Ignore(x => x.Options);
modelBuilder.Entity<WorkflowDefinition>().Property(x => x.ToolVersion).HasConversion(VersionToStringConverter, StringToVersionConverter);
modelBuilder.Entity<WorkflowDefinition>().Property<string>("StringData").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowDefinition>().Property<string>("Data").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowDefinition>().Property(x => x.Description).HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowDefinition>().Property(x => x.MaterializerContext).HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowDefinition>().Property(x => x.BinaryData).HasColumnType("BLOB");
}
}

View file

@ -1,54 +0,0 @@
using Elsa.KeyValues.Entities;
using Elsa.Workflows.Runtime.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Elsa.EntityFrameworkCore.Oracle;
/// <summary>
/// Represents a class that handles entity model creation for SQLite databases.
/// </summary>
public class SetupForRuntime : IEntityModelCreatingHandler
{
/// <inheritdoc />
public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType)
{
if (!dbContext.Database.IsOracle())
return;
// To use data more than 2000 char we have to use NCLOB.
// In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000).
modelBuilder.Entity<StoredTrigger>().Property<string>("SerializedPayload").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowExecutionLogRecord>().Ignore(x => x.ActivityState);
modelBuilder.Entity<WorkflowExecutionLogRecord>().Ignore(x => x.Payload);
modelBuilder.Entity<WorkflowExecutionLogRecord>().Property<string>("SerializedActivityState").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowExecutionLogRecord>().Property<string>("SerializedPayload").HasColumnType("NCLOB");
modelBuilder.Entity<ActivityExecutionRecord>().Ignore(x => x.ActivityState);
modelBuilder.Entity<ActivityExecutionRecord>().Ignore(x => x.Exception);
modelBuilder.Entity<ActivityExecutionRecord>().Ignore(x => x.Payload);
modelBuilder.Entity<ActivityExecutionRecord>().Ignore(x => x.Outputs);
modelBuilder.Entity<ActivityExecutionRecord>().Ignore(x => x.Properties);
modelBuilder.Entity<ActivityExecutionRecord>().Property<string>("SerializedActivityState").HasColumnType("NCLOB");
modelBuilder.Entity<ActivityExecutionRecord>().Property<string>("SerializedException").HasColumnType("NCLOB");
modelBuilder.Entity<ActivityExecutionRecord>().Property<string>("SerializedPayload").HasColumnType("NCLOB");
modelBuilder.Entity<ActivityExecutionRecord>().Property<string>("SerializedOutputs").HasColumnType("NCLOB");
modelBuilder.Entity<ActivityExecutionRecord>().Property<string>("SerializedProperties").HasColumnType("NCLOB");
modelBuilder.Entity<StoredBookmark>().Ignore(x => x.Payload);
modelBuilder.Entity<StoredBookmark>().Ignore(x => x.Metadata);
modelBuilder.Entity<StoredBookmark>().Property<string>("SerializedPayload").HasColumnType("NCLOB");
modelBuilder.Entity<StoredBookmark>().Property<string>("SerializedMetadata").HasColumnType("NCLOB");
modelBuilder.Entity<StoredTrigger>().Ignore(x => x.Payload);
modelBuilder.Entity<StoredTrigger>().Property<string>("SerializedPayload").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowInboxMessage>().Ignore(x => x.Input);
modelBuilder.Entity<WorkflowInboxMessage>().Ignore(x => x.BookmarkPayload);
modelBuilder.Entity<WorkflowInboxMessage>().Property<string>("SerializedInput").HasColumnType("NCLOB");
modelBuilder.Entity<WorkflowInboxMessage>().Property<string>("SerializedBookmarkPayload").HasColumnType("NCLOB");
modelBuilder.Entity<SerializedKeyValuePair>().Property<string>("SerializedValue").HasColumnType("NCLOB");
}
}

View file

@ -31,11 +31,11 @@ public class IdentityElsaDbContext : ElsaDbContextBase
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var config = new Configurations();
modelBuilder.ApplyConfiguration<User>(config);
modelBuilder.ApplyConfiguration<Application>(config);
modelBuilder.ApplyConfiguration<Role>(config);
base.OnModelCreating(modelBuilder);
}
}

View file

@ -28,12 +28,13 @@ public class ManagementElsaDbContext : ElsaDbContextBase
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Ignore<WorkflowState>();
modelBuilder.Ignore<ActivityIncident>();
var config = new Configurations();
modelBuilder.ApplyConfiguration<WorkflowDefinition>(config);
modelBuilder.ApplyConfiguration<WorkflowInstance>(config);
base.OnModelCreating(modelBuilder);
}
}

View file

@ -57,8 +57,6 @@ public class RuntimeElsaDbContext : ElsaDbContextBase
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var config = new Configurations();
modelBuilder.ApplyConfiguration<StoredTrigger>(config);
modelBuilder.ApplyConfiguration<WorkflowExecutionLogRecord>(config);
@ -67,5 +65,7 @@ public class RuntimeElsaDbContext : ElsaDbContextBase
modelBuilder.ApplyConfiguration<BookmarkQueueItem>(config);
modelBuilder.ApplyConfiguration<SerializedKeyValuePair>(config);
modelBuilder.ApplyConfiguration<WorkflowInboxMessage>(config);
base.OnModelCreating(modelBuilder);
}
}

View file

@ -19,7 +19,7 @@ public class TenantsElsaDbContext : ElsaDbContextBase
/// <summary>
/// The alteration plans.
/// </summary>
public DbSet<Tenant> Tenants { get; set; } = default!;
public DbSet<Tenant> Tenants { get; set; } = null!;
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)

View file

@ -54,7 +54,7 @@ public class BookmarkQueueItem : Entity
/// </summary>
public BookmarkFilter CreateBookmarkFilter()
{
return new BookmarkFilter
return new()
{
WorkflowInstanceId = WorkflowInstanceId,
CorrelationId = CorrelationId,