From 0cadc9a712a84753922e4decf6ed19ea01bbbd1d Mon Sep 17 00:00:00 2001 From: gurkanguran <54795879+gurkanguran@users.noreply.github.com> Date: Mon, 2 Jan 2023 22:10:17 +0100 Subject: [PATCH] Implemented PostgreSql provider for data persistence (#3581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implemented PostgreSql provider for data persistence * Refactor Co-authored-by: Gürkan Güran --- Elsa.sln | 7 + Elsa.sln.DotSettings | 1 + ...SqlServerDesignTimeDbContextFactoryBase.cs | 18 ++ ...Elsa.EntityFrameworkCore.PostgreSql.csproj | 36 +++ .../DbContextOptionsBuilderExtensions.cs | 19 ++ .../FodyWeavers.xml | 3 + .../20230102202645_Initial.Designer.cs | 89 ++++++ .../20230102202645_Initial.cs | 79 ++++++ ...tyDefinitionsElsaDbContextModelSnapshot.cs | 86 ++++++ .../Labels/20230102202649_Initial.Designer.cs | 85 ++++++ .../Labels/20230102202649_Initial.cs | 78 ++++++ .../LabelsElsaDbContextModelSnapshot.cs | 82 ++++++ .../20230102202654_Initial.Designer.cs | 187 +++++++++++++ .../Management/20230102202654_Initial.cs | 188 +++++++++++++ .../ManagementElsaDbContextModelSnapshot.cs | 184 +++++++++++++ .../20230102202658_Initial.Designer.cs | 239 ++++++++++++++++ .../Runtime/20230102202658_Initial.cs | 259 ++++++++++++++++++ .../RuntimeElsaDbContextModelSnapshot.cs | 236 ++++++++++++++++ .../DesignTimeDbContextFactory.cs | 9 + .../Modules/ActivityDefinitions/Extensions.cs | 13 + .../Labels/DesignTimeDbContextFactory.cs | 9 + .../Modules/Labels/Extensions.cs | 13 + .../Management/DesignTimeDbContextFactory.cs | 9 + .../Modules/Management/Extensions.cs | 13 + .../Runtime/DesignTimeDbContextFactory.cs | 9 + .../Modules/Runtime/Extensions.cs | 13 + .../generate-migrations.cmd | 4 + .../generate-migrations.sh | 4 + .../Elsa.EntityFrameworkCore.SqlServer.csproj | 2 +- .../Elsa.EntityFrameworkCore.Sqlite.csproj | 4 +- .../Elsa.EntityFrameworkCore.csproj | 6 +- 31 files changed, 1978 insertions(+), 6 deletions(-) create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Abstractions/SqlServerDesignTimeDbContextFactoryBase.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Extensions/DbContextOptionsBuilderExtensions.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/FodyWeavers.xml create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.Designer.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/ActivityDefinitionsElsaDbContextModelSnapshot.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.Designer.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.Designer.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.Designer.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/DesignTimeDbContextFactory.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/Extensions.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/DesignTimeDbContextFactory.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/Extensions.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/DesignTimeDbContextFactory.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/Extensions.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/DesignTimeDbContextFactory.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/Extensions.cs create mode 100644 src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.cmd create mode 100755 src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.sh diff --git a/Elsa.sln b/Elsa.sln index e8b372d61..427134c39 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -144,6 +144,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElsaWorkflowsApp", "templat EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WorkflowSinks", "src\samples\aspnet\Elsa.Samples.WorkflowSinks\Elsa.Samples.WorkflowSinks.csproj", "{536EFB55-EEA1-4761-9A72-D4EA84A6DB70}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.PostgreSql", "src\modules\Elsa.EntityFrameworkCore.PostgreSql\Elsa.EntityFrameworkCore.PostgreSql.csproj", "{AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -358,6 +360,10 @@ Global {536EFB55-EEA1-4761-9A72-D4EA84A6DB70}.Debug|Any CPU.Build.0 = Debug|Any CPU {536EFB55-EEA1-4761-9A72-D4EA84A6DB70}.Release|Any CPU.ActiveCfg = Release|Any CPU {536EFB55-EEA1-4761-9A72-D4EA84A6DB70}.Release|Any CPU.Build.0 = Release|Any CPU + {AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F} @@ -419,5 +425,6 @@ Global {34FBB2D3-4E2B-4411-95F2-C6B56899826A} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5} {15B2ABCB-7460-4E59-A991-10AD9190B1C9} = {26A89A29-FE67-4174-9809-7C63AAD6BD5D} {536EFB55-EEA1-4761-9A72-D4EA84A6DB70} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5} + {AA84DBF7-F70F-4673-8DC2-6EFBE3E9BF83} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} EndGlobalSection EndGlobal diff --git a/Elsa.sln.DotSettings b/Elsa.sln.DotSettings index 7c0987563..2850b89bf 100644 --- a/Elsa.sln.DotSettings +++ b/Elsa.sln.DotSettings @@ -1,4 +1,5 @@  True True + True True \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Abstractions/SqlServerDesignTimeDbContextFactoryBase.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Abstractions/SqlServerDesignTimeDbContextFactoryBase.cs new file mode 100644 index 000000000..e483dc77e --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Abstractions/SqlServerDesignTimeDbContextFactoryBase.cs @@ -0,0 +1,18 @@ +using Elsa.EntityFrameworkCore.Extensions; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; + +namespace Elsa.EntityFrameworkCore.PostgreSql.Abstractions; + +public abstract class PostgreSqlDesignTimeDbContextFactoryBase : IDesignTimeDbContextFactory where TDbContext : DbContext +{ + public TDbContext CreateDbContext(string[] args) + { + var connectionString = args.Any() ? args[0] : "Data Source=local"; + + var builder = new DbContextOptionsBuilder(); + builder.UseElsaPostgreSql(connectionString); + + return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj new file mode 100644 index 000000000..62c1e515c --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj @@ -0,0 +1,36 @@ + + + + + + + net6.0;net7.0 + + Provides PostgreSql implementation and migrations for various modules. + + elsa module persistence efcore postgresql + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Extensions/DbContextOptionsBuilderExtensions.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Extensions/DbContextOptionsBuilderExtensions.cs new file mode 100644 index 000000000..e92895aae --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Extensions/DbContextOptionsBuilderExtensions.cs @@ -0,0 +1,19 @@ +using Elsa.EntityFrameworkCore.Common; +using Microsoft.EntityFrameworkCore; +using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; + +// ReSharper disable once CheckNamespace +namespace Elsa.EntityFrameworkCore.Extensions; + +public static class DbContextOptionsBuilderExtensions +{ + public static DbContextOptionsBuilder UseElsaPostgreSql(this DbContextOptionsBuilder builder, string connectionString, Action? configure = default) => + builder.UseNpgsql(connectionString, db => + { + db + .MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name) + .MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema); + + configure?.Invoke(db); + }); +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/FodyWeavers.xml b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/FodyWeavers.xml new file mode 100644 index 000000000..00e1d9a1c --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.Designer.cs new file mode 100644 index 000000000..545f1ab01 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.Designer.cs @@ -0,0 +1,89 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.ActivityDefinitions +{ + [DbContext(typeof(ActivityDefinitionsElsaDbContext))] + [Migration("20230102202645_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Elsa") + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("IsLatest") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IsLatest") + .HasDatabaseName("IX_ActivityDefinition_IsLatest"); + + b.HasIndex("IsPublished") + .HasDatabaseName("IX_ActivityDefinition_IsPublished"); + + b.HasIndex("Type") + .HasDatabaseName("IX_ActivityDefinition_Type"); + + b.HasIndex("Version") + .HasDatabaseName("IX_ActivityDefinition_Version"); + + b.HasIndex("DefinitionId", "Version") + .IsUnique() + .HasDatabaseName("IX_ActivityDefinition_DefinitionId_Version"); + + b.ToTable("ActivityDefinitions", "Elsa"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.cs new file mode 100644 index 000000000..3d45e8f17 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/20230102202645_Initial.cs @@ -0,0 +1,79 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.ActivityDefinitions +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Elsa"); + + migrationBuilder.CreateTable( + name: "ActivityDefinitions", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + DefinitionId = table.Column(type: "text", nullable: false), + Type = table.Column(type: "text", nullable: false), + DisplayName = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true), + Category = table.Column(type: "text", nullable: true), + Data = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + Version = table.Column(type: "integer", nullable: false), + IsLatest = table.Column(type: "boolean", nullable: false), + IsPublished = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ActivityDefinitions", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_ActivityDefinition_DefinitionId_Version", + schema: "Elsa", + table: "ActivityDefinitions", + columns: new[] { "DefinitionId", "Version" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ActivityDefinition_IsLatest", + schema: "Elsa", + table: "ActivityDefinitions", + column: "IsLatest"); + + migrationBuilder.CreateIndex( + name: "IX_ActivityDefinition_IsPublished", + schema: "Elsa", + table: "ActivityDefinitions", + column: "IsPublished"); + + migrationBuilder.CreateIndex( + name: "IX_ActivityDefinition_Type", + schema: "Elsa", + table: "ActivityDefinitions", + column: "Type"); + + migrationBuilder.CreateIndex( + name: "IX_ActivityDefinition_Version", + schema: "Elsa", + table: "ActivityDefinitions", + column: "Version"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ActivityDefinitions", + schema: "Elsa"); + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/ActivityDefinitionsElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/ActivityDefinitionsElsaDbContextModelSnapshot.cs new file mode 100644 index 000000000..30900fc8d --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/ActivityDefinitions/ActivityDefinitionsElsaDbContextModelSnapshot.cs @@ -0,0 +1,86 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.ActivityDefinitions +{ + [DbContext(typeof(ActivityDefinitionsElsaDbContext))] + partial class ActivityDefinitionsElsaDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Elsa") + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Category") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("IsLatest") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IsLatest") + .HasDatabaseName("IX_ActivityDefinition_IsLatest"); + + b.HasIndex("IsPublished") + .HasDatabaseName("IX_ActivityDefinition_IsPublished"); + + b.HasIndex("Type") + .HasDatabaseName("IX_ActivityDefinition_Type"); + + b.HasIndex("Version") + .HasDatabaseName("IX_ActivityDefinition_Version"); + + b.HasIndex("DefinitionId", "Version") + .IsUnique() + .HasDatabaseName("IX_ActivityDefinition_DefinitionId_Version"); + + b.ToTable("ActivityDefinitions", "Elsa"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.Designer.cs new file mode 100644 index 000000000..3fe59675c --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.Designer.cs @@ -0,0 +1,85 @@ +// +using Elsa.EntityFrameworkCore.Modules.Labels; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Labels +{ + [DbContext(typeof(LabelsElsaDbContext))] + [Migration("20230102202649_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Elsa") + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Labels.Entities.Label", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Color") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Labels", "Elsa"); + }); + + modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("LabelId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionVersionId") + .IsRequired() + .HasColumnType("text"); + + 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 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.cs new file mode 100644 index 000000000..6535fe4f0 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/20230102202649_Initial.cs @@ -0,0 +1,78 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Labels +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Elsa"); + + migrationBuilder.CreateTable( + name: "Labels", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NormalizedName = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Color = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Labels", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WorkflowDefinitionLabels", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + WorkflowDefinitionId = table.Column(type: "text", nullable: false), + WorkflowDefinitionVersionId = table.Column(type: "text", nullable: false), + LabelId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowDefinitionLabels", x => x.Id); + }); + + 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"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Labels", + schema: "Elsa"); + + migrationBuilder.DropTable( + name: "WorkflowDefinitionLabels", + schema: "Elsa"); + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs new file mode 100644 index 000000000..c26b21c6d --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs @@ -0,0 +1,82 @@ +// +using Elsa.EntityFrameworkCore.Modules.Labels; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.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.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Labels.Entities.Label", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Color") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Labels", "Elsa"); + }); + + modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("LabelId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionVersionId") + .IsRequired() + .HasColumnType("text"); + + 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 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.Designer.cs new file mode 100644 index 000000000..cc5c0d13f --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.Designer.cs @@ -0,0 +1,187 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.Management; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management +{ + [DbContext(typeof(ManagementElsaDbContext))] + [Migration("20230102202654_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Elsa") + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BinaryData") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsLatest") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("MaterializerContext") + .HasColumnType("text"); + + b.Property("MaterializerName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("StringData") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + 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("Id") + .HasColumnType("text"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionVersionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("FaultedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("SubStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + 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 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.cs new file mode 100644 index 000000000..7bd41a846 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230102202654_Initial.cs @@ -0,0 +1,188 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Elsa"); + + migrationBuilder.CreateTable( + name: "WorkflowDefinitions", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + DefinitionId = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true), + MaterializerName = table.Column(type: "text", nullable: false), + MaterializerContext = table.Column(type: "text", nullable: true), + StringData = table.Column(type: "text", nullable: true), + BinaryData = table.Column(type: "bytea", nullable: true), + Data = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + Version = table.Column(type: "integer", nullable: false), + IsLatest = table.Column(type: "boolean", nullable: false), + IsPublished = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowDefinitions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WorkflowInstances", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + DefinitionId = table.Column(type: "text", nullable: false), + DefinitionVersionId = table.Column(type: "text", nullable: false), + Version = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "text", nullable: false), + SubStatus = table.Column(type: "text", nullable: false), + CorrelationId = table.Column(type: "text", nullable: true), + Name = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + LastExecutedAt = table.Column(type: "timestamp with time zone", nullable: true), + FinishedAt = table.Column(type: "timestamp with time zone", nullable: true), + CancelledAt = table.Column(type: "timestamp with time zone", nullable: true), + FaultedAt = table.Column(type: "timestamp with time zone", nullable: true), + Data = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowInstances", x => x.Id); + }); + + 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" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "WorkflowDefinitions", + schema: "Elsa"); + + migrationBuilder.DropTable( + name: "WorkflowInstances", + schema: "Elsa"); + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs new file mode 100644 index 000000000..2b7a94a1b --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -0,0 +1,184 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.Management; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.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.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BinaryData") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsLatest") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("MaterializerContext") + .HasColumnType("text"); + + b.Property("MaterializerName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("StringData") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + 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("Id") + .HasColumnType("text"); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionVersionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("FaultedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastExecutedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("SubStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + 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 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.Designer.cs new file mode 100644 index 000000000..fb69a9b9f --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.Designer.cs @@ -0,0 +1,239 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.Runtime; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Runtime +{ + [DbContext(typeof(RuntimeElsaDbContext))] + [Migration("20230102202658_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Elsa") + .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionVersion") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("SubStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + 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.StoredTrigger", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ActivityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + 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("Id") + .HasColumnType("text"); + + b.Property("ActivityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ActivityInstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ActivityType") + .IsRequired() + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("ParentActivityInstanceId") + .HasColumnType("text"); + + b.Property("PayloadData") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowVersion") + .HasColumnType("integer"); + + 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"); + }); + + modelBuilder.Entity("Elsa.Workflows.Runtime.Models.StoredBookmark", b => + { + b.Property("BookmarkId") + .HasColumnType("text"); + + b.Property("ActivityTypeName") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("Hash") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("text"); + + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.cs new file mode 100644 index 000000000..c5c60abde --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/20230102202658_Initial.cs @@ -0,0 +1,259 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Runtime +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Elsa"); + + migrationBuilder.CreateTable( + name: "Bookmarks", + schema: "Elsa", + columns: table => new + { + BookmarkId = table.Column(type: "text", nullable: false), + ActivityTypeName = table.Column(type: "text", nullable: false), + Hash = table.Column(type: "text", nullable: false), + WorkflowInstanceId = table.Column(type: "text", nullable: false), + CorrelationId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Bookmarks", x => x.BookmarkId); + }); + + migrationBuilder.CreateTable( + name: "WorkflowExecutionLogRecords", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + WorkflowDefinitionId = table.Column(type: "text", nullable: false), + WorkflowInstanceId = table.Column(type: "text", nullable: false), + WorkflowVersion = table.Column(type: "integer", nullable: false), + ActivityInstanceId = table.Column(type: "text", nullable: false), + ParentActivityInstanceId = table.Column(type: "text", nullable: true), + ActivityId = table.Column(type: "text", nullable: false), + ActivityType = table.Column(type: "text", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + EventName = table.Column(type: "text", nullable: true), + Message = table.Column(type: "text", nullable: true), + Source = table.Column(type: "text", nullable: true), + PayloadData = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowExecutionLogRecords", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WorkflowStates", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + DefinitionId = table.Column(type: "text", nullable: false), + DefinitionVersion = table.Column(type: "integer", nullable: false), + CorrelationId = table.Column(type: "text", nullable: true), + Status = table.Column(type: "text", nullable: false), + SubStatus = table.Column(type: "text", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + Data = table.Column(type: "text", nullable: true), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowStates", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WorkflowTriggers", + schema: "Elsa", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + WorkflowDefinitionId = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + ActivityId = table.Column(type: "text", nullable: false), + Hash = table.Column(type: "text", nullable: true), + Data = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkflowTriggers", x => x.Id); + }); + + 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"); + } + + /// + 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"); + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs new file mode 100644 index 000000000..4bc2516d5 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs @@ -0,0 +1,236 @@ +// +using System; +using Elsa.EntityFrameworkCore.Modules.Runtime; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Elsa.EntityFrameworkCore.PostgreSql.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.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("DefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionVersion") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("SubStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + 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.StoredTrigger", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ActivityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + 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("Id") + .HasColumnType("text"); + + b.Property("ActivityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ActivityInstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ActivityType") + .IsRequired() + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("ParentActivityInstanceId") + .HasColumnType("text"); + + b.Property("PayloadData") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("WorkflowDefinitionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowVersion") + .HasColumnType("integer"); + + 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"); + }); + + modelBuilder.Entity("Elsa.Workflows.Runtime.Models.StoredBookmark", b => + { + b.Property("BookmarkId") + .HasColumnType("text"); + + b.Property("ActivityTypeName") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorrelationId") + .HasColumnType("text"); + + b.Property("Hash") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("text"); + + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/DesignTimeDbContextFactory.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/DesignTimeDbContextFactory.cs new file mode 100644 index 000000000..24c90106b --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/DesignTimeDbContextFactory.cs @@ -0,0 +1,9 @@ +using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions; +using Elsa.EntityFrameworkCore.PostgreSql.Abstractions; + +namespace Elsa.EntityFrameworkCore.PostgreSql.Modules.ActivityDefinitions; + +// ReSharper disable once UnusedType.Global +public class DesignTimeDbContextFactory : PostgreSqlDesignTimeDbContextFactoryBase +{ +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/Extensions.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/Extensions.cs new file mode 100644 index 000000000..eeefbfdc9 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/ActivityDefinitions/Extensions.cs @@ -0,0 +1,13 @@ +using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions; + +// ReSharper disable once CheckNamespace +namespace Elsa.EntityFrameworkCore.Extensions; + +public static partial class Extensions +{ + public static EFCoreActivityDefinitionsPersistenceFeature UsePostgreSql(this EFCoreActivityDefinitionsPersistenceFeature feature, string connectionString) + { + feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString); + return feature; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/DesignTimeDbContextFactory.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/DesignTimeDbContextFactory.cs new file mode 100644 index 000000000..2b628ce88 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/DesignTimeDbContextFactory.cs @@ -0,0 +1,9 @@ +using Elsa.EntityFrameworkCore.Modules.Labels; +using Elsa.EntityFrameworkCore.PostgreSql.Abstractions; + +namespace Elsa.EntityFrameworkCore.PostgreSql.Modules.Labels; + +// ReSharper disable once UnusedType.Global +public class DesignTimeDbContextFactory : PostgreSqlDesignTimeDbContextFactoryBase +{ +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/Extensions.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/Extensions.cs new file mode 100644 index 000000000..0c60603cb --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Labels/Extensions.cs @@ -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 UsePostgreSql(this EFCoreLabelPersistenceFeature feature, string connectionString) + { + feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString); + return feature; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/DesignTimeDbContextFactory.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/DesignTimeDbContextFactory.cs new file mode 100644 index 000000000..eb9d9247f --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/DesignTimeDbContextFactory.cs @@ -0,0 +1,9 @@ +using Elsa.EntityFrameworkCore.Modules.Management; +using Elsa.EntityFrameworkCore.PostgreSql.Abstractions; + +namespace Elsa.EntityFrameworkCore.PostgreSql.Modules.Management; + +// ReSharper disable once UnusedType.Global +public class DesignTimeDbContextFactory : PostgreSqlDesignTimeDbContextFactoryBase +{ +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/Extensions.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/Extensions.cs new file mode 100644 index 000000000..6f2344c30 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Management/Extensions.cs @@ -0,0 +1,13 @@ +using Elsa.EntityFrameworkCore.Modules.Management; + +// ReSharper disable once CheckNamespace +namespace Elsa.EntityFrameworkCore.Extensions; + +public static partial class Extensions +{ + public static EFCoreManagementPersistenceFeature UsePostgreSql(this EFCoreManagementPersistenceFeature feature, string connectionString) + { + feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString); + return feature; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/DesignTimeDbContextFactory.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/DesignTimeDbContextFactory.cs new file mode 100644 index 000000000..4a261ba43 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/DesignTimeDbContextFactory.cs @@ -0,0 +1,9 @@ +using Elsa.EntityFrameworkCore.Modules.Runtime; +using Elsa.EntityFrameworkCore.PostgreSql.Abstractions; + +namespace Elsa.EntityFrameworkCore.PostgreSql.Modules.Runtime; + +// ReSharper disable once UnusedType.Global +public class DesignTimeRuntimeDbContextFactory : PostgreSqlDesignTimeDbContextFactoryBase +{ +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/Extensions.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/Extensions.cs new file mode 100644 index 000000000..559d051da --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Modules/Runtime/Extensions.cs @@ -0,0 +1,13 @@ +using Elsa.EntityFrameworkCore.Modules.Runtime; + +// ReSharper disable once CheckNamespace +namespace Elsa.EntityFrameworkCore.Extensions; + +public static partial class Extensions +{ + public static EFCoreRuntimePersistenceFeature UsePostgreSql(this EFCoreRuntimePersistenceFeature feature, string connectionString) + { + feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString); + return feature; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.cmd b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.cmd new file mode 100644 index 000000000..2297cbfe9 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.cmd @@ -0,0 +1,4 @@ +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 \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.sh b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.sh new file mode 100755 index 000000000..2297cbfe9 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/generate-migrations.sh @@ -0,0 +1,4 @@ +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 \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj index 8afb22c1e..3a43cb149 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj index 1c3519d70..a26ee4a02 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj @@ -13,8 +13,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/modules/Elsa.EntityFrameworkCore/Elsa.EntityFrameworkCore.csproj b/src/modules/Elsa.EntityFrameworkCore/Elsa.EntityFrameworkCore.csproj index b9391ecdd..bb12113bb 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Elsa.EntityFrameworkCore.csproj +++ b/src/modules/Elsa.EntityFrameworkCore/Elsa.EntityFrameworkCore.csproj @@ -19,9 +19,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive