elsa-core/src/modules/Elsa.Dapper.Migrations/Runtime/V3_3.cs
Sipke Schoorstra 9575cdeecf
Update Dapper Migrations (#6520)
* Update workflow to check for patch version 3.3.3

Revised the GitHub Actions workflow to detect the correct patch branch, updating from version 3.3.2 to 3.3.3. This ensures compatibility with the latest release process.

* Refactor WebhooksFeature to streamline configuration.

Simplified the configuration of sinks, sources, and HTTP clients by using direct actions instead of service-level options. Updated Apply method to finalize configurations and added notification handlers for better extensibility. Improved code readability and maintainability by consolidating logic and removing unnecessary dependencies.

* Update base_version in GitHub Actions workflow

Bump the base_version from 3.3.2 to 3.3.4 in the packages workflow file. This ensures compatibility and uses the latest base version for package management.

* Update release branch check to target patch 3.3.4

Modified the GitHub Actions workflow to check for the `patch/3.3.4` branch instead of `patch/3.3.3` during release events. This ensures compatibility with the latest patch branch in the release process.

* Handle conversion of enumerables to arrays in ObjectConverter (#6508)

* Handle conversion of enumerables to arrays in ObjectConverter

Added functionality to convert enumerables to arrays when the target type is an array. The implementation ensures each item is properly cast to the target array's element type and then added to the resulting array.

* Add unit test for converting object array to double array

This commit introduces a new test ensuring the proper conversion of an object array of doubles to a double array. It verifies both the validity of the conversion and that the result is not null.

* Update base version to 3.3.5 in workflow configuration

Bump the `base_version` from 3.3.4 to 3.3.5 in the GitHub Actions workflow file. Adjust the matching branch reference to correspond with the updated version.

* Add V3.4 migration with schema updates and new column

Introduces Migration V3_4 to modify WorkflowInstances by adding the IsExecuting column. Updates Entity Framework migration to dynamically handle schema changes across tables. Ensures improved compatibility and extendability within the database layer.

* Refactor Dapper migration execution and update database schema. (#6519)

* Refactor migration execution and update database schema.

Replaced RunMigrationsHostedService with RunMigrationsStartupTask using IStartupTask for improved lifecycle management. Updated DapperMigrationsFeature to use the new startup task. Added a new "SerializedProperties" column to ActivityExecutionRecords and ensured proper schema adjustments during migrations.

* Add TenantId column to BookmarkQueueItems table

This commit introduces a nullable TenantId column to the BookmarkQueueItems table. The change ensures better multi-tenancy support by allowing tenant-specific data segregation.
2025-03-20 12:11:05 +01:00

65 lines
2.8 KiB
C#

using System.Diagnostics.CodeAnalysis;
using FluentMigrator;
using JetBrains.Annotations;
using static System.Int32;
namespace Elsa.Dapper.Migrations.Runtime;
/// <inheritdoc />
[Migration(20004, "Elsa:Runtime:V3.3")]
[PublicAPI]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class V3_3 : Migration
{
/// <inheritdoc />
public override void Up()
{
Alter.Table("Triggers").AddColumn("TenantId").AsString().Nullable();
Alter.Table("Bookmarks").AddColumn("TenantId").AsString().Nullable();
Alter.Table("WorkflowExecutionLogRecords").AddColumn("TenantId").AsString().Nullable();
Alter.Table("ActivityExecutionRecords").AddColumn("TenantId").AsString().Nullable();
Alter.Table("ActivityExecutionRecords").AddColumn("SerializedProperties").AsString(MaxValue).Nullable();
Alter.Table("KeyValuePairs").AddColumn("TenantId").AsString().Nullable();
IfDatabase("SqlServer", "Oracle", "MySql", "Postgres")
.Create
.Table("BookmarkQueueItems")
.WithColumn("Id").AsString().PrimaryKey()
.WithColumn("TenantId").AsString().Nullable()
.WithColumn("WorkflowInstanceId").AsString().Nullable()
.WithColumn("CorrelationId").AsString().Nullable()
.WithColumn("BookmarkId").AsString().Nullable()
.WithColumn("StimulusHash").AsString().Nullable()
.WithColumn("ActivityInstanceId").AsString().Nullable()
.WithColumn("ActivityTypeName").AsString().Nullable()
.WithColumn("CreatedAt").AsDateTimeOffset().NotNullable()
;
IfDatabase("Sqlite")
.Create
.Table("BookmarkQueueItems")
.WithColumn("Id").AsString().PrimaryKey()
.WithColumn("TenantId").AsString().Nullable()
.WithColumn("WorkflowInstanceId").AsString().Nullable()
.WithColumn("CorrelationId").AsString().Nullable()
.WithColumn("BookmarkId").AsString().Nullable()
.WithColumn("StimulusHash").AsString().Nullable()
.WithColumn("ActivityInstanceId").AsString().Nullable()
.WithColumn("ActivityTypeName").AsString().Nullable()
.WithColumn("CreatedAt").AsDateTime2().NotNullable()
;
}
/// <inheritdoc />
public override void Down()
{
Delete.Column("TenantId").FromTable("Triggers");
Delete.Column("TenantId").FromTable("Bookmarks");
Delete.Column("TenantId").FromTable("WorkflowExecutionLogRecords");
Delete.Column("TenantId").FromTable("ActivityExecutionRecords");
Delete.Column("SerializedProperties").FromTable("ActivityExecutionRecords");
Delete.Column("TenantId").FromTable("KeyValuePairs");
Rename.Column("Id").OnTable("KeyValuePairs").To("Key");
Delete.Table("BookmarkQueueItems");
}
}