Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

SQLite migrations V3_4, V3_5, and V3_6 incorrectly attempted schema operations (EnsureSchema, RenameTable with newSchema, schema qualifiers on DDL) that SQLite doesn't support, causing tables to become inaccessible. This manifested as the WorkflowInstances table appearing empty while other tables contained data.

Changes

Removed schema operations from SQLite migrations:

  • V3_4 (Management, Runtime, Labels, Identity, Tenants, Alterations): Removed EnsureSchema() and RenameTable() calls
  • V3_5 (Runtime): Removed schema: parameters from AddColumn, AlterColumn, CreateIndex
  • V3_6 (Management): Removed schema: parameters from AddColumn, DropColumn

Before (V3_4 Management):

migrationBuilder.EnsureSchema(name: _schema.Schema);
migrationBuilder.RenameTable(
    name: "WorkflowInstances",
    newName: "WorkflowInstances",
    newSchema: _schema.Schema);
migrationBuilder.AddColumn<bool>(
    name: "IsExecuting",
    schema: _schema.Schema,  // ← Problem
    table: "WorkflowInstances",
    type: "INTEGER");

After:

// SQLite does not support schemas, so we only add the column without schema qualifiers
migrationBuilder.AddColumn<bool>(
    name: "IsExecuting",
    table: "WorkflowInstances",
    type: "INTEGER");

Impact

Users who already applied V3_4+ migrations may need to recreate their SQLite databases. New installations will work correctly.

Original prompt

This section details on the original issue you should resolve

<issue_title>The WorkflowInstances table is always empty when using SQLite as the storage, while other tables have records.</issue_title>
<issue_description>## Description
使用的是3.5.1版本,升级后也是这样
services.AddElsa(elsa => { var dbConn = $"Data Source=d:\\eap_workflow.db"; elsa.UseWorkflows(workflow => { workflow.WithWorkflowExecutionPipeline(pileline => pileline.UseMiddleware<WorkflowExecMiddleware>().UseExceptionHandling().UseDefaultActivityScheduler()); workflow.WithActivityExecutionPipeline(pileline => pileline.UseMiddleware<ActivityExecMiddleware>().UseDefaultActivityInvoker()); }); elsa.UseWorkflowManagement(management => { management.UseEntityFrameworkCore(efcore => { efcore.UseSqlite(dbConn); }); }); elsa.UseWorkflowRuntime(runtime => { runtime.UseEntityFrameworkCore(efcore => { efcore.UseSqlite(dbConn); }); }); elsa.UseJavaScript(); elsa.UseRetention(retention => { retention.SweepInterval = TimeSpan.FromDays(1); retention.AddDeletePolicy("delete 2 days", provider => { var threshold = DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(2)); return new RetentionWorkflowInstanceFilter() { TimestampFilters = [ new TimestampFilter() { Column = nameof(WorkflowInstance.FinishedAt), Operator = TimestampFilterOperator.LessThanOrEqual, Timestamp = threshold } ], WorkflowStatus = WorkflowStatus.Finished }; }); }); }).AddActivitiesFrom<TActivity>().AddWorkflowsFrom<TActivity>();

Steps to Reproduce

</issue_description>

<agent_instructions>Try and see if you can reproduce this with a brand new ASP.NET Core project that references Elsa 3.5.1 packages using the startup code provided by the OP.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@sfmskywalker Can you perhaps share a sample project that reproduces this issue?

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


This change is Reviewable

Copilot AI changed the title [WIP] Fix empty WorkflowInstances table with SQLite storage Fix SQLite migrations incorrectly using schema operations Dec 3, 2025
Copilot AI requested a review from sfmskywalker December 3, 2025 14:58
@sfmskywalker sfmskywalker force-pushed the main branch 2 times, most recently from 4e58970 to ae1bb77 Compare December 10, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The WorkflowInstances table is always empty when using SQLite as the storage, while other tables have records.

2 participants