Bundle from worker to grain

This commit is contained in:
2025-09-15 12:56:59 +07:00
parent 77e6ce0789
commit 63bc7bbe59
19 changed files with 2112 additions and 79 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class ChangeRequestIdToGuid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Convert BundleBacktestRequests.RequestId from varchar to uuid
// First, ensure all values are valid UUIDs or convert them
migrationBuilder.Sql(@"
UPDATE ""BundleBacktestRequests""
SET ""RequestId"" = gen_random_uuid()::text
WHERE ""RequestId"" IS NULL OR ""RequestId"" = '' OR
""RequestId"" !~ '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$';
");
// Now convert the column type using the USING clause
migrationBuilder.Sql(@"
ALTER TABLE ""BundleBacktestRequests""
ALTER COLUMN ""RequestId"" TYPE uuid USING ""RequestId""::uuid;
");
// Convert Backtests.RequestId from varchar to uuid
// First, ensure all values are valid UUIDs or convert them
migrationBuilder.Sql(@"
UPDATE ""Backtests""
SET ""RequestId"" = gen_random_uuid()::text
WHERE ""RequestId"" IS NULL OR ""RequestId"" = '' OR
""RequestId"" !~ '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$';
");
// Now convert the column type using the USING clause
migrationBuilder.Sql(@"
ALTER TABLE ""Backtests""
ALTER COLUMN ""RequestId"" TYPE uuid USING ""RequestId""::uuid;
");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
// Convert BundleBacktestRequests.RequestId from uuid back to varchar
migrationBuilder.Sql(@"
ALTER TABLE ""BundleBacktestRequests""
ALTER COLUMN ""RequestId"" TYPE character varying(255) USING ""RequestId""::text;
");
// Convert Backtests.RequestId from uuid back to varchar
migrationBuilder.Sql(@"
ALTER TABLE ""Backtests""
ALTER COLUMN ""RequestId"" TYPE character varying(255) USING ""RequestId""::text;
");
}
}
}

View File

@@ -176,10 +176,9 @@ namespace Managing.Infrastructure.Databases.Migrations
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("RequestId")
.IsRequired()
b.Property<Guid>("RequestId")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
.HasColumnType("uuid");
b.Property<double>("Score")
.HasColumnType("double precision");
@@ -339,10 +338,9 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<string>("ProgressInfo")
.HasColumnType("text");
b.Property<string>("RequestId")
.IsRequired()
b.Property<Guid>("RequestId")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
.HasColumnType("uuid");
b.Property<string>("ResultsJson")
.IsRequired()