fix: align backend APIs and upload flow
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace FileService.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(FileDbContext))]
|
||||
[Migration("20260909000300_AsyncUploadResult")]
|
||||
public partial class AsyncUploadResult : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
AlterStringColumns(migrationBuilder, narrowing: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ChatType",
|
||||
table: "upload_files",
|
||||
type: "varchar(16)",
|
||||
maxLength: 16,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsPublic",
|
||||
table: "upload_files",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SourceTaskId",
|
||||
table: "upload_files",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "TargetId",
|
||||
table: "upload_files",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ChatType",
|
||||
table: "upload_tasks",
|
||||
type: "varchar(16)",
|
||||
maxLength: 16,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FailureReason",
|
||||
table: "upload_tasks",
|
||||
type: "varchar(500)",
|
||||
maxLength: 500,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ResultFileId",
|
||||
table: "upload_tasks",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "TargetId",
|
||||
table: "upload_tasks",
|
||||
type: "char(36)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_upload_files_SourceTaskId",
|
||||
table: "upload_files",
|
||||
column: "SourceTaskId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_upload_files_checksum",
|
||||
table: "upload_files",
|
||||
columns: new[] { "checksum_algorithm", "checksum_value", "IsDeleted" });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex("IX_upload_files_checksum", "upload_files");
|
||||
migrationBuilder.DropIndex("IX_upload_files_SourceTaskId", "upload_files");
|
||||
migrationBuilder.DropColumn("ChatType", "upload_files");
|
||||
migrationBuilder.DropColumn("IsPublic", "upload_files");
|
||||
migrationBuilder.DropColumn("SourceTaskId", "upload_files");
|
||||
migrationBuilder.DropColumn("TargetId", "upload_files");
|
||||
migrationBuilder.DropColumn("ChatType", "upload_tasks");
|
||||
migrationBuilder.DropColumn("FailureReason", "upload_tasks");
|
||||
migrationBuilder.DropColumn("ResultFileId", "upload_tasks");
|
||||
migrationBuilder.DropColumn("TargetId", "upload_tasks");
|
||||
AlterStringColumns(migrationBuilder, narrowing: false);
|
||||
}
|
||||
|
||||
|
||||
private static void AlterStringColumns(MigrationBuilder migrationBuilder, bool narrowing)
|
||||
{
|
||||
var columns = new (string Table, string Column, int Length, bool Nullable)[]
|
||||
{
|
||||
("upload_files", "FileName", 255, false),
|
||||
("upload_files", "ContentType", 255, false),
|
||||
("upload_files", "checksum_algorithm", 16, false),
|
||||
("upload_files", "checksum_value", 128, false),
|
||||
("upload_files", "storage_provider", 64, false),
|
||||
("upload_files", "storage_bucket", 255, false),
|
||||
("upload_files", "storage_key", 1024, false),
|
||||
("upload_files", "storage_region", 128, true),
|
||||
("upload_tasks", "FileName", 255, false),
|
||||
("upload_tasks", "ContentType", 255, false),
|
||||
("upload_tasks", "checksum_algorithm", 16, false),
|
||||
("upload_tasks", "checksum_value", 128, false),
|
||||
("upload_tasks", "storage_provider", 64, false),
|
||||
("upload_tasks", "storage_bucket", 255, false),
|
||||
("upload_tasks", "storage_key", 1024, false),
|
||||
("upload_tasks", "storage_region", 128, true)
|
||||
};
|
||||
|
||||
foreach (var (table, column, length, nullable) in columns)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: column,
|
||||
table: table,
|
||||
type: narrowing ? $"varchar({length})" : "longtext",
|
||||
maxLength: narrowing ? length : null,
|
||||
nullable: nullable,
|
||||
oldClrType: typeof(string),
|
||||
oldType: narrowing ? "longtext" : $"varchar({length})",
|
||||
oldMaxLength: narrowing ? null : length,
|
||||
oldNullable: nullable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,18 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("FileService.Domain.Entities.UploadFile", b =>
|
||||
{
|
||||
b.Property<string>("ChatType")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<DateTimeOffset>("CreationTime")
|
||||
.HasColumnType("datetime(6)");
|
||||
@@ -41,7 +46,8 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<long>("FileSize")
|
||||
.HasColumnType("bigint");
|
||||
@@ -49,27 +55,38 @@ namespace FileService.Infrastructure.Migrations
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsPublic")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTimeOffset?>("ModificationTime")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("SourceTaskId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("TargetId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.ComplexProperty<Dictionary<string, object>>("CheckSum", "FileService.Domain.Entities.UploadFile.CheckSum#CheckSum", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<string>("Algorithm")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)")
|
||||
.HasColumnName("checksum_algorithm");
|
||||
|
||||
b1.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("checksum_value");
|
||||
});
|
||||
|
||||
@@ -79,38 +96,50 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
b1.Property<string>("Bucket")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)")
|
||||
.HasColumnName("storage_bucket");
|
||||
|
||||
b1.Property<string>("ObjectKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)")
|
||||
.HasColumnName("storage_key");
|
||||
|
||||
b1.Property<string>("Region")
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("storage_region");
|
||||
|
||||
b1.Property<string>("StorageProvider")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)")
|
||||
.HasColumnName("storage_provider");
|
||||
});
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SourceTaskId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("upload_files", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileService.Domain.Entities.UploadTask", b =>
|
||||
{
|
||||
b.Property<string>("ChatType")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)");
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<Guid>("ConversationId")
|
||||
.HasColumnType("char(36)");
|
||||
@@ -123,20 +152,31 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<long>("FileSize")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("FailureReason")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTimeOffset?>("ModificationTime")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid?>("ResultFileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("TargetId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("UploaderId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
@@ -146,12 +186,14 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
b1.Property<string>("Algorithm")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("varchar(16)")
|
||||
.HasColumnName("checksum_algorithm");
|
||||
|
||||
b1.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("checksum_value");
|
||||
});
|
||||
|
||||
@@ -161,21 +203,25 @@ namespace FileService.Infrastructure.Migrations
|
||||
|
||||
b1.Property<string>("Bucket")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("varchar(255)")
|
||||
.HasColumnName("storage_bucket");
|
||||
|
||||
b1.Property<string>("ObjectKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)")
|
||||
.HasColumnName("storage_key");
|
||||
|
||||
b1.Property<string>("Region")
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("storage_region");
|
||||
|
||||
b1.Property<string>("StorageProvider")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)")
|
||||
.HasColumnName("storage_provider");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user