Skip to content

Conversation

infofromca
Copy link
Contributor

Fix #18301

await SchemaBuilder.AlterIndexTableAsync<WorkflowIndex>(table =>
{
table.AddColumn<string>("WorkflowStatus");
table.AddColumn<int>("WorkflowStatus");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to create a new version for altering the table. I.e. create a new method UpdateFrom3Async etc.

@infofromca infofromca requested a review from gvkries September 19, 2025 17:01
await SchemaBuilder.AlterIndexTableAsync<WorkflowIndex>(table =>
{
// Drop the existing column (if it exists)
table.DropColumn("WorkflowStatus");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the actual table contains data in the WorkflowStatus column?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe admin should export the data to recipe to deal with it.
but OC deal with the data in the similar way:
// SqLite does not support dropping columns.
try
{
await SchemaBuilder.AlterIndexTableAsync(table => table
.DropColumn("Time"));

 await SchemaBuilder.AlterIndexTableAsync<TimeFieldIndex>(table => table
     .AddColumn<TimeSpan>("Time", column => column.Nullable()));

}
catch
{
_logger.LogWarning("Failed to alter 'Time' column. This is not an error when using SqLite");
}

Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastienros Is changing the column type like done here and in

// SqLite does not support dropping columns.
try
{
await SchemaBuilder.AlterIndexTableAsync<TimeFieldIndex>(table => table
.DropColumn("Time"));
await SchemaBuilder.AlterIndexTableAsync<TimeFieldIndex>(table => table
.AddColumn<TimeSpan>("Time", column => column.Nullable()));
}
catch
{
_logger.LogWarning("Failed to alter 'Time' column. This is not an error when using SqLite");
}

actually a good idea?

"CreatedUtc")
);

return 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Create method should always return the latest version (and contain the latest changes as well).

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.

OrchardCore.Workflows.Trimming.Services.WorkflowTrimmingBackgroundTask|ERROR
3 participants