Implemented PostgreSql provider for data persistence (#3581)

* Implemented PostgreSql provider for data persistence

* Refactor

Co-authored-by: Gürkan Güran <grkngrn@gmail.com>
This commit is contained in:
gurkanguran 2023-01-02 22:10:17 +01:00 committed by GitHub
parent 4272d5a49c
commit 0cadc9a712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1978 additions and 6 deletions

View file

@ -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

View file

@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=abcdefghijklmnopqrstuvwxyz/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deconstructor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Postgre/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Telnyx/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -0,0 +1,18 @@
using Elsa.EntityFrameworkCore.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Elsa.EntityFrameworkCore.PostgreSql.Abstractions;
public abstract class PostgreSqlDesignTimeDbContextFactoryBase<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.UseElsaPostgreSql(connectionString);
return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
}

View file

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Description>
Provides PostgreSql implementation and migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore postgresql</PackageTags>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.1" />
</ItemGroup>
</Project>

View file

@ -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<NpgsqlDbContextOptionsBuilder>? configure = default) =>
builder.UseNpgsql(connectionString, db =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema);
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,89 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("Category")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<bool>("IsLatest")
.HasColumnType("boolean");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.ActivityDefinitions
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "ActivityDefinitions",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DefinitionId = table.Column<string>(type: "text", nullable: false),
Type = table.Column<string>(type: "text", nullable: false),
DisplayName = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
Category = table.Column<string>(type: "text", nullable: true),
Data = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Version = table.Column<int>(type: "integer", nullable: false),
IsLatest = table.Column<bool>(type: "boolean", nullable: false),
IsPublished = table.Column<bool>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ActivityDefinitions",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,86 @@
// <auto-generated />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("Category")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<bool>("IsLatest")
.HasColumnType("boolean");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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
}
}
}

View file

@ -0,0 +1,85 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("Color")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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
}
}
}

View file

@ -0,0 +1,78 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Labels
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "Labels",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
NormalizedName = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
Color = table.Column<string>(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<string>(type: "text", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "text", nullable: false),
WorkflowDefinitionVersionId = table.Column<string>(type: "text", nullable: false),
LabelId = table.Column<string>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Labels",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowDefinitionLabels",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,82 @@
// <auto-generated />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("Color")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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
}
}
}

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;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
[Migration("20230102202654_Initial")]
partial class Initial
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("text");
b.Property<byte[]>("BinaryData")
.HasColumnType("bytea");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsLatest")
.HasColumnType("boolean");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("MaterializerContext")
.HasColumnType("text");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("StringData")
.HasColumnType("text");
b.Property<int>("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<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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
}
}
}

View file

@ -0,0 +1,188 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "WorkflowDefinitions",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DefinitionId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
MaterializerName = table.Column<string>(type: "text", nullable: false),
MaterializerContext = table.Column<string>(type: "text", nullable: true),
StringData = table.Column<string>(type: "text", nullable: true),
BinaryData = table.Column<byte[]>(type: "bytea", nullable: true),
Data = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Version = table.Column<int>(type: "integer", nullable: false),
IsLatest = table.Column<bool>(type: "boolean", nullable: false),
IsPublished = table.Column<bool>(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<string>(type: "text", nullable: false),
DefinitionId = table.Column<string>(type: "text", nullable: false),
DefinitionVersionId = table.Column<string>(type: "text", nullable: false),
Version = table.Column<int>(type: "integer", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
SubStatus = table.Column<string>(type: "text", nullable: false),
CorrelationId = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LastExecutedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
FinishedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
CancelledAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
FaultedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Data = table.Column<string>(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" });
}
/// <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;
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<string>("Id")
.HasColumnType("text");
b.Property<byte[]>("BinaryData")
.HasColumnType("bytea");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsLatest")
.HasColumnType("boolean");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("MaterializerContext")
.HasColumnType("text");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("StringData")
.HasColumnType("text");
b.Property<int>("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<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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
}
}
}

View file

@ -0,0 +1,239 @@
// <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;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
[Migration("20230102202658_Initial")]
partial class Initial
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DefinitionVersion")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("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<string>("Id")
.HasColumnType("text");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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<string>("Id")
.HasColumnType("text");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EventName")
.HasColumnType("text");
b.Property<string>("Message")
.HasColumnType("text");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("text");
b.Property<string>("PayloadData")
.HasColumnType("text");
b.Property<string>("Source")
.HasColumnType("text");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("timestamp with time zone");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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<string>("BookmarkId")
.HasColumnType("text");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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
}
}
}

View file

@ -0,0 +1,259 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Runtime
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "Bookmarks",
schema: "Elsa",
columns: table => new
{
BookmarkId = table.Column<string>(type: "text", nullable: false),
ActivityTypeName = table.Column<string>(type: "text", nullable: false),
Hash = table.Column<string>(type: "text", nullable: false),
WorkflowInstanceId = table.Column<string>(type: "text", nullable: false),
CorrelationId = table.Column<string>(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<string>(type: "text", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "text", nullable: false),
WorkflowInstanceId = table.Column<string>(type: "text", nullable: false),
WorkflowVersion = table.Column<int>(type: "integer", nullable: false),
ActivityInstanceId = table.Column<string>(type: "text", nullable: false),
ParentActivityInstanceId = table.Column<string>(type: "text", nullable: true),
ActivityId = table.Column<string>(type: "text", nullable: false),
ActivityType = table.Column<string>(type: "text", nullable: false),
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EventName = table.Column<string>(type: "text", nullable: true),
Message = table.Column<string>(type: "text", nullable: true),
Source = table.Column<string>(type: "text", nullable: true),
PayloadData = table.Column<string>(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<string>(type: "text", nullable: false),
DefinitionId = table.Column<string>(type: "text", nullable: false),
DefinitionVersion = table.Column<int>(type: "integer", nullable: false),
CorrelationId = table.Column<string>(type: "text", nullable: true),
Status = table.Column<string>(type: "text", nullable: false),
SubStatus = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Data = table.Column<string>(type: "text", nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(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<string>(type: "text", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ActivityId = table.Column<string>(type: "text", nullable: false),
Hash = table.Column<string>(type: "text", nullable: true),
Data = table.Column<string>(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");
}
/// <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,236 @@
// <auto-generated />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DefinitionVersion")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("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<string>("Id")
.HasColumnType("text");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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<string>("Id")
.HasColumnType("text");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EventName")
.HasColumnType("text");
b.Property<string>("Message")
.HasColumnType("text");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("text");
b.Property<string>("PayloadData")
.HasColumnType("text");
b.Property<string>("Source")
.HasColumnType("text");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("timestamp with time zone");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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<string>("BookmarkId")
.HasColumnType("text");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CorrelationId")
.HasColumnType("text");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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
}
}
}

View file

@ -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<ActivityDefinitionsElsaDbContext>
{
}

View file

@ -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;
}
}

View file

@ -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<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 UsePostgreSql(this EFCoreLabelPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
return feature;
}
}

View file

@ -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<ManagementElsaDbContext>
{
}

View file

@ -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;
}
}

View file

@ -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<RuntimeElsaDbContext>
{
}

View file

@ -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;
}
}

View file

@ -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

View file

@ -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

View file

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.12">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -13,8 +13,8 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.12">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -19,9 +19,9 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.12">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>