Skip to content

Commit f1b85a1

Browse files
authored
Merge pull request #4876 from elsa-workflows/issue(4875)
Add GZip compression for WorkflowInstance Data field on EF Core
2 parents 9c7f651 + 611c72f commit f1b85a1

File tree

43 files changed

+2985
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2985
-44
lines changed

Elsa.sln

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D
2323
NuGet.Config = NuGet.Config
2424
packages.props = packages.props
2525
README.md = README.md
26-
update-migrations.sh = update-migrations.sh
2726
EndProjectSection
2827
EndProject
2928
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{0354F050-3992-4DD4-B0EE-5FBA04AC72B6}"
@@ -308,6 +307,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.Heartbe
308307
EndProject
309308
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MassTransit.AzureServiceBus", "src\modules\Elsa.MassTransit.AzureServiceBus\Elsa.MassTransit.AzureServiceBus.csproj", "{AFEB799E-82C3-4D02-9D5C-766BB8DEF004}"
310309
EndProject
310+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{C80C8231-D35C-4ACC-9ED6-9F3DB221535E}"
311+
ProjectSection(SolutionItems) = preProject
312+
migrations\efcore-3.1.sh = migrations\efcore-3.1.sh
313+
migrations\efcore-3.0.sh = migrations\efcore-3.0.sh
314+
EndProjectSection
315+
EndProject
311316
Global
312317
GlobalSection(SolutionConfigurationPlatforms) = preSolution
313318
Debug|Any CPU = Debug|Any CPU

Elsa.sln.DotSettings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
99
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
1010
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
11+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EF/@EntryIndexedValue">EF</s:String>
1112
<s:Boolean x:Key="/Default/UserDictionary/Words/=downloadables/@EntryIndexedValue">True</s:Boolean>
1213
<s:Boolean x:Key="/Default/UserDictionary/Words/=initializable/@EntryIndexedValue">True</s:Boolean>
1314
<s:Boolean x:Key="/Default/UserDictionary/Words/=materializers/@EntryIndexedValue">True</s:Boolean>
@@ -16,4 +17,5 @@
1617
<s:Boolean x:Key="/Default/UserDictionary/Words/=Postgre/@EntryIndexedValue">True</s:Boolean>
1718
<s:Boolean x:Key="/Default/UserDictionary/Words/=startable/@EntryIndexedValue">True</s:Boolean>
1819
<s:Boolean x:Key="/Default/UserDictionary/Words/=Telnyx/@EntryIndexedValue">True</s:Boolean>
19-
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unschedule/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
20+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unschedule/@EntryIndexedValue">True</s:Boolean>
21+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Zstd/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

update-migrations.sh renamed to generate-migrations-initial copy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env zsh
22

33
# Define the modules to update
4-
mods=("Runtime")
4+
mods=("Management")
55
# mods=("Alterations" "Runtime" "Management" "Identity" "Labels")
66

77
# Define the list of providers

migrations/efcore-3.0.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env zsh
2+
3+
# Define the modules to update
4+
mods=("Management")
5+
# mods=("Alterations" "Runtime" "Management" "Identity" "Labels")
6+
7+
# Define the list of providers
8+
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
9+
# providers=("SqlServer")
10+
11+
# Connection strings for each provider
12+
typeset -A connStrings
13+
connStrings=(
14+
MySql "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;"
15+
SqlServer ""
16+
Sqlite ""
17+
PostgreSql ""
18+
)
19+
20+
# Loop through each module
21+
for module in "${mods[@]}"; do
22+
# Loop through each provider
23+
for provider in "${providers[@]}"; do
24+
providerPath="../src/modules/Elsa.EntityFrameworkCore.$provider"
25+
migrationsPath="Migrations/$module"
26+
27+
echo "Updating migrations for $provider..."
28+
echo "Provider path: ${providerPath:?}/${migrationsPath}"
29+
echo "Migrations path: $migrationsPath"
30+
echo "Connection string: ${connStrings[$provider]}"
31+
32+
# 1. Delete the existing migrations folder
33+
rm -rf "${providerPath:?}/${migrationsPath}"
34+
35+
# 2. Run the migrations command
36+
dotnet ef migrations add Initial -c "$module"ElsaDbContext -p "$providerPath" -o "$migrationsPath" -- --connectionString "${connStrings[$provider]}"
37+
done
38+
done

migrations/efcore-3.1.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env zsh
2+
3+
# Define the modules to update
4+
mods=("Management" "Runtime")
5+
# mods=("Alterations" "Runtime" "Management" "Identity" "Labels")
6+
7+
# Define the list of providers
8+
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
9+
# providers=("SqlServer")
10+
11+
# Connection strings for each provider
12+
typeset -A connStrings
13+
connStrings=(
14+
MySql "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;"
15+
SqlServer ""
16+
Sqlite ""
17+
PostgreSql ""
18+
)
19+
20+
# Loop through each module
21+
for module in "${mods[@]}"; do
22+
# Loop through each provider
23+
for provider in "${providers[@]}"; do
24+
providerPath="../src/modules/Elsa.EntityFrameworkCore.$provider"
25+
migrationsPath="Migrations/$module"
26+
27+
echo "Updating migrations for $provider..."
28+
echo "Provider path: ${providerPath:?}/${migrationsPath}"
29+
echo "Migrations path: $migrationsPath"
30+
echo "Connection string: ${connStrings[$provider]}"
31+
32+
# 2. Run the migrations command
33+
dotnet ef migrations add V3_1 -c "$module"ElsaDbContext -p "$providerPath" -o "$migrationsPath" -- --connectionString "${connStrings[$provider]}"
34+
done
35+
done

src/bundles/Elsa.Server.Web/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Elsa.MongoDb.Modules.Identity;
1616
using Elsa.MongoDb.Modules.Management;
1717
using Elsa.MongoDb.Modules.Runtime;
18+
using Elsa.Workflows.Management.Compression;
1819
using Microsoft.Data.Sqlite;
1920
using Microsoft.Extensions.Options;
2021
using Proto.Persistence.Sqlite;
@@ -29,6 +30,7 @@
2930
const bool useMassTransit = false;
3031
const bool useMassTransitAzureServiceBus = true;
3132
const bool useMassTransitRabbitMq = false;
33+
const bool useZipCompression = true;
3234

3335
var builder = WebApplication.CreateBuilder(args);
3436
var services = builder.Services;
@@ -106,6 +108,9 @@
106108
else
107109
ef.UseSqlite(sqliteConnectionString);
108110
});
111+
112+
if(useZipCompression)
113+
management.SetCompressionAlgorithm(nameof(Zstd));
109114
})
110115
.UseWorkflowRuntime(runtime =>
111116
{

src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20240203235204_V3_1.Designer.cs

Lines changed: 196 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management
6+
{
7+
/// <inheritdoc />
8+
public partial class V31 : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.AddColumn<string>(
14+
name: "DataCompressionAlgorithm",
15+
schema: "Elsa",
16+
table: "WorkflowInstances",
17+
type: "longtext",
18+
nullable: true)
19+
.Annotation("MySql:CharSet", "utf8mb4");
20+
}
21+
22+
/// <inheritdoc />
23+
protected override void Down(MigrationBuilder migrationBuilder)
24+
{
25+
migrationBuilder.DropColumn(
26+
name: "DataCompressionAlgorithm",
27+
schema: "Elsa",
28+
table: "WorkflowInstances");
29+
}
30+
}
31+
}

src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
#pragma warning disable 612, 618
1818
modelBuilder
1919
.HasDefaultSchema("Elsa")
20-
.HasAnnotation("ProductVersion", "7.0.11")
20+
.HasAnnotation("ProductVersion", "7.0.2")
2121
.HasAnnotation("Relational:MaxIdentifierLength", 64);
2222

2323
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
@@ -113,6 +113,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
113113
b.Property<string>("Data")
114114
.HasColumnType("longtext");
115115

116+
b.Property<string>("DataCompressionAlgorithm")
117+
.HasColumnType("longtext");
118+
116119
b.Property<string>("DefinitionId")
117120
.IsRequired()
118121
.HasColumnType("varchar(255)");

0 commit comments

Comments
 (0)