Description
Elsa.Persistence.EFCore.MySql runtime migration 20251204150235_V3_6 fails on MySQL with utf8mb4 when creating the unique index on the Triggers table.
Error message:
MySqlConnector.MySqlException: Specified key was too long; max key length is 3072 bytes
The failing SQL is:
CREATE UNIQUE INDEX `IX_StoredTrigger_Unique_WorkflowDefinitionId_Hash_ActivityId_Ten`
ON `Triggers` (`WorkflowDefinitionId`, `Hash`, `ActivityId`, `TenantId`);
It looks like this index can exceed MySQL InnoDB's maximum index key length when the involved columns are varchar(255) using utf8mb4.
Steps to Reproduce
-
Create an empty MySQL database using utf8mb4.
CREATE DATABASE Test
CHARACTER SET utf8mb4
COLLATE utf8mb4_0900_ai_ci;
-
Create a minimal .NET 8 console app.
-
Small correction for the reproduction steps: step 3 should include these packages:
- Elsa 3.6.1
- Elsa.Persistence.EFCore.MySql 3.6.1
- Microsoft.Extensions.Hosting 9.0.13
-
Register Elsa workflow management and runtime persistence with MySQL and enable migrations:
using Elsa.Extensions;
using Elsa.Persistence.EFCore.Extensions;
using Elsa.Persistence.EFCore.Modules.Management;
using Elsa.Persistence.EFCore.Modules.Runtime;
using Microsoft.Extensions.Hosting;
const string connectionString =
"Server=XXX;Port=XXX;Database=Test;User ID=XXX;Password=XXX;Allow User Variables=True;Connection Timeout=5";
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddElsa(elsa =>
{
elsa.UseWorkflowManagement(management =>
management.UseEntityFrameworkCore(ef =>
{
ef.UseMySql(connectionString);
ef.RunMigrations = true;
}));
elsa.UseWorkflowRuntime(runtime =>
runtime.UseEntityFrameworkCore(ef =>
{
ef.UseMySql(connectionString);
ef.RunMigrations = true;
}));
});
using var host = builder.Build();
await host.StartAsync();
await host.StopAsync();
- Run the application.
Reproduction rate: every time on a clean MySQL 8.1.0 database using utf8mb4.
Expected Behavior
The Elsa MySQL runtime migrations should complete successfully.
Actual Behavior
The workflow management migrations complete, but the runtime migration 20251204150235_V3_6 fails when creating this index:
CREATE UNIQUE INDEX `IX_StoredTrigger_Unique_WorkflowDefinitionId_Hash_ActivityId_Ten`
ON `Triggers` (`WorkflowDefinitionId`, `Hash`, `ActivityId`, `TenantId`);
The migration remains pending, so the same error happens again on the next startup.
Screenshots
Not applicable.
Environment
- Elsa Package Version:
Elsa 3.6.1
Elsa.Persistence.EFCore.MySql 3.6.1
- Database:
- MySQL 8.1.0
- Database charset:
utf8mb4
- Database collation:
utf8mb4_0900_ai_ci
- Server charset:
utf8mb4
- Server collation:
utf8mb4_0900_ai_ci
- Operating System:
- Target Framework:
Log Output
Applying migration '20251204150235_V3_6'.
ALTER TABLE `Triggers` MODIFY COLUMN `ActivityId` varchar(255) CHARACTER SET utf8mb4 NOT NULL;
CREATE UNIQUE INDEX `IX_StoredTrigger_Unique_WorkflowDefinitionId_Hash_ActivityId_Ten`
ON `Triggers` (`WorkflowDefinitionId`, `Hash`, `ActivityId`, `TenantId`);
MySqlConnector.MySqlException (0x80004005): Specified key was too long; max key length is 3072 bytes
Troubleshooting Attempts
I reproduced this with a minimal console application using the official Elsa registration path and ef.RunMigrations = true.
I also tried creating a separate database using utf8mb3, but the migration still uses utf8mb4 explicitly in the generated DDL.
I checked older package lines and noticed that Elsa.EntityFrameworkCore.MySql 3.5.3 does not appear to include this specific runtime migration/index. The issue seems related to the 20251204150235_V3_6 migration introduced in the 3.6.x line.
Additional Context
This appears related to MySQL InnoDB index length limits with utf8mb4. The index includes multiple string columns, each mapped as varchar(255) / utf8mb4.
The failing migration seems to have been introduced to include TenantId in the stored trigger unique index.
Related Issues
None found.
Description
Elsa.Persistence.EFCore.MySqlruntime migration20251204150235_V3_6fails on MySQL withutf8mb4when creating the unique index on theTriggerstable.Error message:
The failing SQL is:
It looks like this index can exceed MySQL InnoDB's maximum index key length when the involved columns are
varchar(255)usingutf8mb4.Steps to Reproduce
Create an empty MySQL database using
utf8mb4.CREATE DATABASE Test
CHARACTER SET utf8mb4
COLLATE utf8mb4_0900_ai_ci;
Create a minimal .NET 8 console app.
Small correction for the reproduction steps: step 3 should include these packages:
Register Elsa workflow management and runtime persistence with MySQL and enable migrations:
Reproduction rate: every time on a clean MySQL 8.1.0 database using
utf8mb4.Expected Behavior
The Elsa MySQL runtime migrations should complete successfully.
Actual Behavior
The workflow management migrations complete, but the runtime migration
20251204150235_V3_6fails when creating this index:The migration remains pending, so the same error happens again on the next startup.
Screenshots
Not applicable.
Environment
Elsa3.6.1Elsa.Persistence.EFCore.MySql3.6.1utf8mb4utf8mb4_0900_ai_ciutf8mb4utf8mb4_0900_ai_ciLog Output
Troubleshooting Attempts
I reproduced this with a minimal console application using the official Elsa registration path and
ef.RunMigrations = true.I also tried creating a separate database using
utf8mb3, but the migration still usesutf8mb4explicitly in the generated DDL.I checked older package lines and noticed that
Elsa.EntityFrameworkCore.MySql3.5.3 does not appear to include this specific runtime migration/index. The issue seems related to the20251204150235_V3_6migration introduced in the 3.6.x line.Additional Context
This appears related to MySQL InnoDB index length limits with
utf8mb4. The index includes multiple string columns, each mapped asvarchar(255)/utf8mb4.The failing migration seems to have been introduced to include
TenantIdin the stored trigger unique index.Related Issues
None found.