Merge remote-tracking branch 'origin/v3' into v3

This commit is contained in:
Sipke Schoorstra 2023-05-26 20:37:20 +02:00
commit 3fb78f020c
33 changed files with 2278 additions and 18 deletions

View file

@ -200,6 +200,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.HttpEnd
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Environments", "src\modules\Elsa.Environments\Elsa.Environments.csproj", "{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.MySql", "src\modules\Elsa.EntityFrameworkCore.MySql\Elsa.EntityFrameworkCore.MySql.csproj", "{8DC74562-1F06-4AFA-8308-8A779E8812A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -510,6 +512,10 @@ Global
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Release|Any CPU.Build.0 = Release|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
@ -599,5 +605,6 @@ Global
{3212A999-4AC4-4911-9AA4-92AB906BCB5E} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{165ACC9D-B67C-4B49-A818-ECFD247C899C} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{8DC74562-1F06-4AFA-8308-8A779E8812A3} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,18 @@
using Elsa.EntityFrameworkCore.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Elsa.EntityFrameworkCore.MySql.Abstractions;
public abstract class MySqlDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
{
public TDbContext CreateDbContext(string[] args)
{
var connectionString = args.Any() ? args[0] : "Data Source=local";
var builder = new DbContextOptionsBuilder<TDbContext>();
builder.UseElsaMySql(connectionString);
return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
}

View file

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Description>
Provides MySql implementation and migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore mysql</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,21 @@
using Elsa.EntityFrameworkCore.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
// ReSharper disable once CheckNamespace
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 =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema)
.SchemaBehavior(MySqlSchemaBehavior.Ignore);
configure?.Invoke(db);
});
}

View file

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

View file

@ -0,0 +1,128 @@
// <auto-generated />
using Elsa.EntityFrameworkCore.Modules.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Identity
{
[DbContext(typeof(IdentityElsaDbContext))]
[Migration("20230517105414_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Identity.Entities.Application", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("HashedApiKey")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedApiKeySalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedClientSecret")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedClientSecretSalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Roles");
b.HasKey("Id");
b.HasIndex("ClientId")
.IsUnique()
.HasDatabaseName("IX_Application_ClientId");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Application_Name");
b.ToTable("Applications", "Elsa");
});
modelBuilder.Entity("Elsa.Identity.Entities.Role", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Permissions")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Permissions");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Role_Name");
b.ToTable("Roles", "Elsa");
});
modelBuilder.Entity("Elsa.Identity.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("HashedPassword")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedPasswordSalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Roles");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_User_Name");
b.ToTable("Users", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,132 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Identity
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Applications",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ClientId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedClientSecret = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedClientSecretSalt = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedApiKey = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedApiKeySalt = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Roles = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Applications", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Roles",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Permissions = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Users",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedPassword = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
HashedPasswordSalt = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Roles = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Application_ClientId",
schema: "Elsa",
table: "Applications",
column: "ClientId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Application_Name",
schema: "Elsa",
table: "Applications",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Role_Name",
schema: "Elsa",
table: "Roles",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_User_Name",
schema: "Elsa",
table: "Users",
column: "Name",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Applications",
schema: "Elsa");
migrationBuilder.DropTable(
name: "Roles",
schema: "Elsa");
migrationBuilder.DropTable(
name: "Users",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,125 @@
// <auto-generated />
using Elsa.EntityFrameworkCore.Modules.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Identity
{
[DbContext(typeof(IdentityElsaDbContext))]
partial class IdentityElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Identity.Entities.Application", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("HashedApiKey")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedApiKeySalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedClientSecret")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedClientSecretSalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Roles");
b.HasKey("Id");
b.HasIndex("ClientId")
.IsUnique()
.HasDatabaseName("IX_Application_ClientId");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Application_Name");
b.ToTable("Applications", "Elsa");
});
modelBuilder.Entity("Elsa.Identity.Entities.Role", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Permissions")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Permissions");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Role_Name");
b.ToTable("Roles", "Elsa");
});
modelBuilder.Entity("Elsa.Identity.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("HashedPassword")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("HashedPasswordSalt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("Roles");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_User_Name");
b.ToTable("Users", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,82 @@
// <auto-generated />
using Elsa.EntityFrameworkCore.Modules.Labels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Labels
{
[DbContext(typeof(LabelsElsaDbContext))]
[Migration("20230517105302_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("Color")
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionVersionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("LabelId")
.HasDatabaseName("WorkflowDefinitionLabel_LabelId");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionId");
b.HasIndex("WorkflowDefinitionVersionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionVersionId");
b.ToTable("WorkflowDefinitionLabels", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,92 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Labels
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Labels",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Color = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Labels", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowDefinitionLabels",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowDefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowDefinitionVersionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LabelId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowDefinitionLabels", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_LabelId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "LabelId");
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "WorkflowDefinitionId");
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_WorkflowDefinitionVersionId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "WorkflowDefinitionVersionId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Labels",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowDefinitionLabels",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,79 @@
// <auto-generated />
using Elsa.EntityFrameworkCore.Modules.Labels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Labels
{
[DbContext(typeof(LabelsElsaDbContext))]
partial class LabelsElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("Color")
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionVersionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("LabelId")
.HasDatabaseName("WorkflowDefinitionLabel_LabelId");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionId");
b.HasIndex("WorkflowDefinitionVersionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionVersionId");
b.ToTable("WorkflowDefinitionLabels", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,187 @@
// <auto-generated />
using System;
using Elsa.EntityFrameworkCore.Modules.Management;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
[Migration("20230517105323_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<byte[]>("BinaryData")
.HasColumnType("longblob");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<bool>("IsLatest")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsPublished")
.HasColumnType("tinyint(1)");
b.Property<string>("MaterializerContext")
.HasColumnType("longtext");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("StringData")
.HasColumnType("longtext");
b.Property<bool?>("UsableAsActivity")
.HasColumnType("tinyint(1)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_WorkflowDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_WorkflowDefinition_IsPublished");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowDefinition_Name");
b.HasIndex("Version")
.HasDatabaseName("IX_WorkflowDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_WorkflowDefinition_DefinitionId_Version");
b.ToTable("WorkflowDefinitions", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowInstance", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("datetime(6)");
b.Property<string>("CorrelationId")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("datetime(6)");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("datetime(6)");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowInstance_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowInstance_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_DefinitionId");
b.HasIndex("FaultedAt")
.HasDatabaseName("IX_WorkflowInstance_FaultedAt");
b.HasIndex("FinishedAt")
.HasDatabaseName("IX_WorkflowInstance_FinishedAt");
b.HasIndex("LastExecutedAt")
.HasDatabaseName("IX_WorkflowInstance_LastExecutedAt");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowInstance_Name");
b.HasIndex("Status")
.HasDatabaseName("IX_WorkflowInstance_Status");
b.HasIndex("SubStatus")
.HasDatabaseName("IX_WorkflowInstance_SubStatus");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus");
b.HasIndex("SubStatus", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_SubStatus_DefinitionId");
b.HasIndex("Status", "SubStatus", "DefinitionId", "Version")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version");
b.ToTable("WorkflowInstances", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,210 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowDefinitions",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MaterializerName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
MaterializerContext = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
StringData = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
BinaryData = table.Column<byte[]>(type: "longblob", nullable: true),
UsableAsActivity = table.Column<bool>(type: "tinyint(1)", nullable: true),
Data = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
IsLatest = table.Column<bool>(type: "tinyint(1)", nullable: false),
IsPublished = table.Column<bool>(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowDefinitions", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowInstances",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DefinitionVersionId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Version = table.Column<int>(type: "int", nullable: false),
Status = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SubStatus = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CorrelationId = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
LastExecutedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
FinishedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
CancelledAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
FaultedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
Data = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowInstances", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_DefinitionId_Version",
schema: "Elsa",
table: "WorkflowDefinitions",
columns: new[] { "DefinitionId", "Version" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_IsLatest",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "IsLatest");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_IsPublished",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "IsPublished");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_Name",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_Version",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "Version");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_CorrelationId",
schema: "Elsa",
table: "WorkflowInstances",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_CreatedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
column: "DefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_FaultedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "FaultedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_FinishedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "FinishedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_LastExecutedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "LastExecutedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Name",
schema: "Elsa",
table: "WorkflowInstances",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status",
schema: "Elsa",
table: "WorkflowInstances",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "DefinitionId" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_SubStatus",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "SubStatus" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "SubStatus", "DefinitionId", "Version" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_SubStatus",
schema: "Elsa",
table: "WorkflowInstances",
column: "SubStatus");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_SubStatus_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "SubStatus", "DefinitionId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WorkflowDefinitions",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowInstances",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,184 @@
// <auto-generated />
using System;
using Elsa.EntityFrameworkCore.Modules.Management;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
partial class ManagementElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<byte[]>("BinaryData")
.HasColumnType("longblob");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<bool>("IsLatest")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsPublished")
.HasColumnType("tinyint(1)");
b.Property<string>("MaterializerContext")
.HasColumnType("longtext");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("StringData")
.HasColumnType("longtext");
b.Property<bool?>("UsableAsActivity")
.HasColumnType("tinyint(1)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_WorkflowDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_WorkflowDefinition_IsPublished");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowDefinition_Name");
b.HasIndex("Version")
.HasDatabaseName("IX_WorkflowDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_WorkflowDefinition_DefinitionId_Version");
b.ToTable("WorkflowDefinitions", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowInstance", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("datetime(6)");
b.Property<string>("CorrelationId")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("datetime(6)");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("datetime(6)");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowInstance_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowInstance_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_DefinitionId");
b.HasIndex("FaultedAt")
.HasDatabaseName("IX_WorkflowInstance_FaultedAt");
b.HasIndex("FinishedAt")
.HasDatabaseName("IX_WorkflowInstance_FinishedAt");
b.HasIndex("LastExecutedAt")
.HasDatabaseName("IX_WorkflowInstance_LastExecutedAt");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowInstance_Name");
b.HasIndex("Status")
.HasDatabaseName("IX_WorkflowInstance_Status");
b.HasIndex("SubStatus")
.HasDatabaseName("IX_WorkflowInstance_SubStatus");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus");
b.HasIndex("SubStatus", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_SubStatus_DefinitionId");
b.HasIndex("Status", "SubStatus", "DefinitionId", "Version")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version");
b.ToTable("WorkflowInstances", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,246 @@
// <auto-generated />
using System;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
[Migration("20230517105351_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("CorrelationId")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("DefinitionVersion")
.HasColumnType("int");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowState_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowState_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowState_DefinitionId");
b.HasIndex("UpdatedAt")
.HasDatabaseName("IX_WorkflowState_UpdatedAt");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowState_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus");
b.HasIndex("Status", "SubStatus", "DefinitionId", "DefinitionVersion")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion");
b.ToTable("WorkflowStates", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredBookmark", b =>
{
b.Property<string>("BookmarkId")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("CorrelationId")
.HasColumnType("longtext");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("BookmarkId");
b.HasIndex(new[] { "ActivityTypeName" }, "IX_StoredBookmark_ActivityTypeName");
b.HasIndex(new[] { "ActivityTypeName", "Hash" }, "IX_StoredBookmark_ActivityTypeName_Hash");
b.HasIndex(new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" }, "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId");
b.HasIndex(new[] { "Hash" }, "IX_StoredBookmark_Hash");
b.HasIndex(new[] { "WorkflowInstanceId" }, "IX_StoredBookmark_WorkflowInstanceId");
b.ToTable("Bookmarks", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredTrigger", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("Hash")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("Hash")
.HasDatabaseName("IX_StoredTrigger_Hash");
b.HasIndex("Name")
.HasDatabaseName("IX_StoredTrigger_Name");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_StoredTrigger_WorkflowDefinitionId");
b.ToTable("WorkflowTriggers", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.WorkflowExecutionLogRecord", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityData")
.HasColumnType("longtext");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("EventName")
.HasColumnType("varchar(255)");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<string>("NodeId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("varchar(255)");
b.Property<string>("PayloadData")
.HasColumnType("longtext");
b.Property<string>("Source")
.HasColumnType("longtext");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("WorkflowVersion")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityId");
b.HasIndex("ActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityInstanceId");
b.HasIndex("ActivityType")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityType");
b.HasIndex("EventName")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_EventName");
b.HasIndex("ParentActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ParentActivityInstanceId");
b.HasIndex("Timestamp")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_Timestamp");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowDefinitionId");
b.HasIndex("WorkflowInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowInstanceId");
b.HasIndex("WorkflowVersion")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowVersion");
b.ToTable("WorkflowExecutionLogRecords", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,300 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Runtime
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Bookmarks",
schema: "Elsa",
columns: table => new
{
BookmarkId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ActivityTypeName = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Hash = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowInstanceId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CorrelationId = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Data = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Bookmarks", x => x.BookmarkId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowExecutionLogRecords",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowDefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowInstanceId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowVersion = table.Column<int>(type: "int", nullable: false),
ActivityInstanceId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ParentActivityInstanceId = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ActivityId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ActivityType = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
NodeId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Timestamp = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
EventName = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Message = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Source = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ActivityData = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PayloadData = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowExecutionLogRecords", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowStates",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DefinitionVersion = table.Column<int>(type: "int", nullable: false),
CorrelationId = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SubStatus = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
Data = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowStates", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WorkflowTriggers",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
WorkflowDefinitionId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ActivityId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Hash = table.Column<string>(type: "varchar(255)", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Data = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowTriggers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName",
schema: "Elsa",
table: "Bookmarks",
column: "ActivityTypeName");
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName_Hash",
schema: "Elsa",
table: "Bookmarks",
columns: new[] { "ActivityTypeName", "Hash" });
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId",
schema: "Elsa",
table: "Bookmarks",
columns: new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" });
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_Hash",
schema: "Elsa",
table: "Bookmarks",
column: "Hash");
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_WorkflowInstanceId",
schema: "Elsa",
table: "Bookmarks",
column: "WorkflowInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityType",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityType");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_EventName",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "EventName");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ParentActivityInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ParentActivityInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_Timestamp",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "Timestamp");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowVersion",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowVersion");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_CorrelationId",
schema: "Elsa",
table: "WorkflowStates",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_CreatedAt",
schema: "Elsa",
table: "WorkflowStates",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_DefinitionId",
schema: "Elsa",
table: "WorkflowStates",
column: "DefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_DefinitionId",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "DefinitionId" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_SubStatus",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "SubStatus" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "SubStatus", "DefinitionId", "DefinitionVersion" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_UpdatedAt",
schema: "Elsa",
table: "WorkflowStates",
column: "UpdatedAt");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_Hash",
schema: "Elsa",
table: "WorkflowTriggers",
column: "Hash");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_Name",
schema: "Elsa",
table: "WorkflowTriggers",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowTriggers",
column: "WorkflowDefinitionId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Bookmarks",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowExecutionLogRecords",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowStates",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowTriggers",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,243 @@
// <auto-generated />
using System;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
partial class RuntimeElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("CorrelationId")
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("DefinitionVersion")
.HasColumnType("int");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowState_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowState_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowState_DefinitionId");
b.HasIndex("UpdatedAt")
.HasDatabaseName("IX_WorkflowState_UpdatedAt");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowState_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus");
b.HasIndex("Status", "SubStatus", "DefinitionId", "DefinitionVersion")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion");
b.ToTable("WorkflowStates", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredBookmark", b =>
{
b.Property<string>("BookmarkId")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("CorrelationId")
.HasColumnType("longtext");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("BookmarkId");
b.HasIndex(new[] { "ActivityTypeName" }, "IX_StoredBookmark_ActivityTypeName");
b.HasIndex(new[] { "ActivityTypeName", "Hash" }, "IX_StoredBookmark_ActivityTypeName_Hash");
b.HasIndex(new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" }, "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId");
b.HasIndex(new[] { "Hash" }, "IX_StoredBookmark_Hash");
b.HasIndex(new[] { "WorkflowInstanceId" }, "IX_StoredBookmark_WorkflowInstanceId");
b.ToTable("Bookmarks", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredTrigger", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<string>("Hash")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("Hash")
.HasDatabaseName("IX_StoredTrigger_Hash");
b.HasIndex("Name")
.HasDatabaseName("IX_StoredTrigger_Name");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_StoredTrigger_WorkflowDefinitionId");
b.ToTable("WorkflowTriggers", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.WorkflowExecutionLogRecord", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ActivityData")
.HasColumnType("longtext");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("EventName")
.HasColumnType("varchar(255)");
b.Property<string>("Message")
.HasColumnType("longtext");
b.Property<string>("NodeId")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("varchar(255)");
b.Property<string>("PayloadData")
.HasColumnType("longtext");
b.Property<string>("Source")
.HasColumnType("longtext");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("varchar(255)");
b.Property<int>("WorkflowVersion")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityId");
b.HasIndex("ActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityInstanceId");
b.HasIndex("ActivityType")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityType");
b.HasIndex("EventName")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_EventName");
b.HasIndex("ParentActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ParentActivityInstanceId");
b.HasIndex("Timestamp")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_Timestamp");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowDefinitionId");
b.HasIndex("WorkflowInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowInstanceId");
b.HasIndex("WorkflowVersion")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowVersion");
b.ToTable("WorkflowExecutionLogRecords", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,13 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.MySql.Abstractions;
using JetBrains.Annotations;
namespace Elsa.EntityFrameworkCore.MySql.Modules.Identity;
/// <summary>
/// The design-time factory for the <see cref="IdentityElsaDbContext"/>.
/// </summary>
[PublicAPI]
public class DesignTimeIdentityDbContextFactory : MySqlDesignTimeDbContextFactoryBase<IdentityElsaDbContext>
{
}

View file

@ -0,0 +1,19 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
public static partial class Extensions
{
/// <summary>
/// Configures the <see cref="EFCoreIdentityPersistenceFeature"/> feature with MySql persistence providers.
/// </summary>
/// <param name="feature">The feature to configure.</param>
/// <param name="connectionString">The connection string to use.</param>
/// <returns>The configured feature.</returns>
public static EFCoreIdentityPersistenceFeature UseMySql(this EFCoreIdentityPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.MySql.Abstractions;
namespace Elsa.EntityFrameworkCore.MySql.Modules.Labels;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : MySqlDesignTimeDbContextFactoryBase<LabelsElsaDbContext>
{
}

View file

@ -0,0 +1,13 @@
using Elsa.EntityFrameworkCore.Modules.Labels;
// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
public static partial class Extensions
{
public static EFCoreLabelPersistenceFeature UseMySql(this EFCoreLabelPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.MySql.Abstractions;
namespace Elsa.EntityFrameworkCore.MySql.Modules.Management;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : MySqlDesignTimeDbContextFactoryBase<ManagementElsaDbContext>
{
}

View file

@ -0,0 +1,30 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using JetBrains.Annotations;
// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
/// <summary>
/// Extends EF Core features.
/// </summary>
[PublicAPI]
public static partial class Extensions
{
public static EFCoreWorkflowDefinitionPersistenceFeature UseMySql(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
public static EFCoreWorkflowInstancePersistenceFeature UseMySql(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
public static EFCoreWorkflowManagementPersistenceFeature UseMySql(this EFCoreWorkflowManagementPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.EntityFrameworkCore.MySql.Abstractions;
namespace Elsa.EntityFrameworkCore.MySql.Modules.Runtime;
// ReSharper disable once UnusedType.Global
public class DesignTimeRuntimeDbContextFactory : MySqlDesignTimeDbContextFactoryBase<RuntimeElsaDbContext>
{
}

View file

@ -0,0 +1,19 @@
using Elsa.EntityFrameworkCore.Modules.Runtime;
// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;
public static partial class Extensions
{
public static EFCoreDefaultWorkflowRuntimePersistenceFeature UseMySql(this EFCoreDefaultWorkflowRuntimePersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
public static EFCoreExecutionLogRecordPersistenceFeature UseMySql(this EFCoreExecutionLogRecordPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaMySql(connectionString);
return feature;
}
}

View file

@ -0,0 +1,5 @@
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime
dotnet ef migrations add Initial -c IdentityElsaDbContext -o Migrations/Identity

View file

@ -0,0 +1,5 @@
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime
dotnet ef migrations add Initial -c IdentityElsaDbContext -o Migrations/Identity

View file

@ -1,5 +1,3 @@
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
using Elsa.Expressions;
using Elsa.Expressions.Contracts;
using Elsa.Expressions.Models;
@ -9,6 +7,8 @@ using Elsa.Workflows.Core.Activities.Flowchart.Models;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;
using JetBrains.Annotations;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
namespace Elsa.Workflows.Core.Activities.Flowchart.Activities;
@ -33,17 +33,29 @@ public class FlowSwitch : Activity
[Input(UIHint = "flow-switch-editor")] public ICollection<FlowSwitchCase> Cases { get; set; } = new List<FlowSwitchCase>();
/// <summary>
/// The switch mode determines whether the first match should be scheduled, or all matches.
/// </summary>
[Input(Description = "The switch mode determines whether the first match should be scheduled, or all matches.")]
public Input<SwitchMode> Mode { get; set; } = new(SwitchMode.MatchFirst);
/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var matchingCase = await FindMatchingCaseAsync(context.ExpressionExecutionContext);
var outcome = matchingCase?.Label ?? "Default";
var matchingCases = await FindMatchingCasesAsync(context.ExpressionExecutionContext);
var hasAnyMatches = matchingCases.Any();
await context.CompleteActivityAsync(new Outcomes(outcome));
var mode = context.Get(Mode);
var results = mode == SwitchMode.MatchFirst ? hasAnyMatches ? new[] { matchingCases.First() } : Array.Empty<FlowSwitchCase>() : matchingCases.ToArray();
var outcomes = hasAnyMatches ? results.Select(r => r.Label).ToArray() : new[] { "Default" };
await context.CompleteActivityAsync(new Outcomes(outcomes));
}
private async Task<FlowSwitchCase?> FindMatchingCaseAsync(ExpressionExecutionContext context)
private async Task<IEnumerable<FlowSwitchCase>> FindMatchingCasesAsync(ExpressionExecutionContext context)
{
var matchingCases = new List<FlowSwitchCase>();
var expressionEvaluator = context.GetRequiredService<IExpressionEvaluator>();
foreach (var switchCase in Cases)
@ -51,10 +63,12 @@ public class FlowSwitch : Activity
var result = await expressionEvaluator.EvaluateAsync<bool?>(switchCase.Condition, context);
if (result == true)
return switchCase;
{
matchingCases.Add(switchCase);
}
}
return null;
return matchingCases;
}
}

View file

@ -50,6 +50,12 @@ public class Switch : Activity
)]
public ICollection<SwitchCase> Cases { get; set; } = new List<SwitchCase>();
/// <summary>
/// The switch mode determines whether the first match should be scheduled, or all matches.
/// </summary>
[Input(Description = "The switch mode determines whether the first match should be scheduled, or all matches.")]
public Input<SwitchMode> Mode { get; set; } = new(SwitchMode.MatchFirst);
/// <summary>
/// The default activity to schedule when no case matches.
/// </summary>
@ -59,19 +65,28 @@ public class Switch : Activity
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
context.Set(Output, Expression);
var matchingCase = await FindMatchingCaseAsync(context.ExpressionExecutionContext);
var matchingCases = await FindMatchingCasesAsync(context.ExpressionExecutionContext);
var hasAnyMatches = matchingCases.Any();
if (matchingCase != null)
var mode = context.Get(Mode);
var results = mode == SwitchMode.MatchFirst ? hasAnyMatches ? new[] { matchingCases.First() } : Array.Empty<SwitchCase>() : matchingCases.ToArray();
if (hasAnyMatches)
{
await context.ScheduleActivityAsync(matchingCase.Activity, OnChildActivityCompletedAsync);
foreach (var result in results)
{
await context.ScheduleActivityAsync(result.Activity, OnChildActivityCompletedAsync);
}
return;
}
await context.ScheduleActivityAsync(Default, OnChildActivityCompletedAsync);
}
private async Task<SwitchCase?> FindMatchingCaseAsync(ExpressionExecutionContext context)
private async Task<IEnumerable<SwitchCase>> FindMatchingCasesAsync(ExpressionExecutionContext context)
{
var matchingCases = new List<SwitchCase>();
var expressionEvaluator = context.GetRequiredService<IExpressionEvaluator>();
foreach (var switchCase in Cases)
@ -79,10 +94,12 @@ public class Switch : Activity
var result = await expressionEvaluator.EvaluateAsync<bool?>(switchCase.Condition, context);
if (result == true)
return switchCase;
{
matchingCases.Add(switchCase);
}
}
return null;
return matchingCases;
}
private async ValueTask OnChildActivityCompletedAsync(ActivityExecutionContext context, ActivityExecutionContext childContext)

View file

@ -0,0 +1,15 @@
namespace Elsa.Workflows.Core.Models
{
public enum SwitchMode
{
/// <summary>
/// Yields the outcome of the first condition evaluating to true.
/// </summary>
MatchFirst,
/// <summary>
/// Yields the outcome of all conditions evaluating to true.
/// </summary>
MatchAny
}
}

View file

@ -7,4 +7,4 @@ namespace Elsa.Workflows.Core.Notifications;
/// <summary>
/// A domain event that is published everytime a burst of execution completes.
/// </summary>
public record WorkflowExecuted(Workflow Workflow, WorkflowState WorkflowState) : INotification;
public record WorkflowExecuted(Workflow Workflow, WorkflowState WorkflowState, WorkflowExecutionContext WorkflowExecutionContext) : INotification;

View file

@ -6,4 +6,4 @@ namespace Elsa.Workflows.Core.Notifications;
/// <summary>
/// A domain event that is published before a burst of execution begins.
/// </summary>
public record WorkflowExecuting(Workflow Workflow) : INotification;
public record WorkflowExecuting(Workflow Workflow, WorkflowExecutionContext WorkflowExecutionContext) : INotification;

View file

@ -165,7 +165,7 @@ public class WorkflowRunner : IWorkflowRunner
var cancellationToken = workflowExecutionContext.CancellationToken;
// Publish domain event.
await _eventPublisher.PublishAsync(new WorkflowExecuting(workflow), cancellationToken);
await _eventPublisher.PublishAsync(new WorkflowExecuting(workflow, workflowExecutionContext), cancellationToken);
// Transition into the Running state.
workflowExecutionContext.TransitionTo(WorkflowSubStatus.Executing);
@ -182,7 +182,7 @@ public class WorkflowRunner : IWorkflowRunner
var result = workflow.ResultVariable?.Get(workflowExecutionContext.MemoryRegister);
// Publish domain event.
await _eventPublisher.PublishAsync(new WorkflowExecuted(workflow, workflowState), cancellationToken);
await _eventPublisher.PublishAsync(new WorkflowExecuted(workflow, workflowState, workflowExecutionContext), cancellationToken);
// Return workflow execution result containing state + bookmarks.
return new RunWorkflowResult(workflowState, workflowExecutionContext.Workflow, result);