fix: widen postgres text columns for migration

This commit is contained in:
2026-04-29 23:54:50 +08:00
parent b72a4fd6b5
commit 24b901dddd
4 changed files with 640 additions and 6 deletions
@@ -124,7 +124,6 @@ public sealed class LiveRecorderDbContext : DbContext, IUnitOfWork
builder.Property(static x => x.Level).HasConversion<int>();
builder.Property(static x => x.Category).HasMaxLength(128);
builder.Property(static x => x.Message).HasMaxLength(512);
builder.Property(static x => x.Detail).HasMaxLength(4000);
builder.HasIndex(static x => x.CreatedAt);
builder.HasIndex(static x => x.RecordSessionId);
});
@@ -134,7 +133,6 @@ public sealed class LiveRecorderDbContext : DbContext, IUnitOfWork
builder.ToTable("AppSettings");
builder.HasKey(static x => x.Id);
builder.Property(static x => x.Key).HasMaxLength(128);
builder.Property(static x => x.Value).HasMaxLength(4000);
builder.HasIndex(static x => x.Key).IsUnique();
});
@@ -0,0 +1,582 @@
// <auto-generated />
using System;
using LiveRecorder.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace LiveRecorder.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(LiveRecorderDbContext))]
[Migration("20260429153158_WidenLargeTextColumns")]
partial class WidenLargeTextColumns
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("LiveRecorder.Domain.Entities.AppSetting", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Key")
.IsUnique();
b.ToTable("AppSettings", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.LiveRoom", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Alias")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("AnchorId")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("AnchorName")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<int>("AvailabilityStatus")
.HasColumnType("integer");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<string>("CoverUrl")
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool?>("DanmakuIncludeNonChatEventsOverride")
.HasColumnType("boolean");
b.Property<int?>("DanmakuMinPollIntervalMillisecondsOverride")
.HasColumnType("integer");
b.Property<int?>("DanmakuRetryDelayMaxSecondsOverride")
.HasColumnType("integer");
b.Property<bool?>("EnableAutoReconnectOverride")
.HasColumnType("boolean");
b.Property<bool?>("EnableDanmakuRecordingOverride")
.HasColumnType("boolean");
b.Property<bool>("HasSentLiveNotificationForCurrentSession")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property<bool>("IsPinned")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<bool>("IsPriority")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<DateTimeOffset?>("LastAutoStartDecisionAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastAutoStartDecisionCode")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("LastAutoStartDecisionDetail")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("LastAutoStartDecisionSummary")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTimeOffset?>("LastCheckedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("LastStartRecordingTriggeredAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedUrl")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<int?>("OutputFormatOverride")
.HasColumnType("integer");
b.Property<int>("Platform")
.HasColumnType("integer");
b.Property<int?>("PollingIntervalSecondsOverride")
.HasColumnType("integer");
b.Property<string>("PreferredQualityOverride")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<int?>("ReadWriteTimeoutMillisecondsOverride")
.HasColumnType("integer");
b.Property<int?>("ReconnectDelayMaxSecondsOverride")
.HasColumnType("integer");
b.Property<int?>("RecordingTemplateOverride")
.HasColumnType("integer");
b.Property<string>("Remark")
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<string>("RoomId")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<int?>("SaveModeOverride")
.HasColumnType("integer");
b.Property<int?>("SegmentDurationMinutesOverride")
.HasColumnType("integer");
b.Property<string>("SourceUrl")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<string>("Title")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Platform", "RoomId")
.IsUnique();
b.ToTable("LiveRooms", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordResult", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DanmakuFilePath")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<int>("DanmakuMessageCount")
.HasColumnType("integer");
b.Property<bool>("DeletedLocalFilesAfterUpload")
.HasColumnType("boolean");
b.Property<double?>("DurationSeconds")
.HasColumnType("double precision");
b.Property<string>("ErrorMessage")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("FilePath")
.IsRequired()
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<long?>("FileSizeBytes")
.HasColumnType("bigint");
b.Property<int>("FinalStatus")
.HasColumnType("integer");
b.Property<string>("LastUploadProvider")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<DateTimeOffset?>("LastUploadedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RecordTaskId")
.HasColumnType("uuid");
b.Property<string>("RemoteDanmakuPath")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("RemoteVideoPath")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("UploadErrorMessage")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<int>("UploadStatus")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("RecordTaskId")
.IsUnique();
b.ToTable("RecordResults", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("ActiveSegmentIndex")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("EndedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ErrorMessage")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<Guid>("LiveRoomId")
.HasColumnType("uuid");
b.Property<int>("OutputFormat")
.HasColumnType("integer");
b.Property<string>("OutputPathPattern")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("PreferredQuality")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<int?>("RecorderProcessId")
.HasColumnType("integer");
b.Property<int>("SaveMode")
.HasColumnType("integer");
b.Property<int>("SegmentCount")
.HasColumnType("integer");
b.Property<DateTimeOffset?>("StartedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<string>("StreamUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LiveRoomId");
b.ToTable("RecordSessions", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordTask", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double?>("DurationSeconds")
.HasColumnType("double precision");
b.Property<DateTimeOffset?>("EndedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ErrorMessage")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<Guid>("LiveRoomId")
.HasColumnType("uuid");
b.Property<string>("OutputFilePath")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<int>("OutputFormat")
.HasColumnType("integer");
b.Property<string>("PreferredQuality")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("RecordSessionId")
.HasColumnType("uuid");
b.Property<int?>("RecorderProcessId")
.HasColumnType("integer");
b.Property<int>("SegmentIndex")
.HasColumnType("integer");
b.Property<DateTimeOffset?>("StartedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<string>("StreamUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LiveRoomId");
b.HasIndex("RecordSessionId", "SegmentIndex");
b.ToTable("RecordTasks", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.SystemLogEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Category")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Detail")
.HasColumnType("text");
b.Property<int>("Level")
.HasColumnType("integer");
b.Property<Guid?>("LiveRoomId")
.HasColumnType("uuid");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<Guid?>("RecordSessionId")
.HasColumnType("uuid");
b.Property<Guid?>("RecordTaskId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.HasIndex("RecordSessionId");
b.ToTable("SystemLogEntries", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.UserAccount", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("PasswordHash")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.HasKey("Id");
b.HasIndex("Username")
.IsUnique();
b.ToTable("UserAccounts", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.UserSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("RevokedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Token")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<Guid>("UserAccountId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("Token")
.IsUnique();
b.HasIndex("UserAccountId");
b.ToTable("UserSessions", (string)null);
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordResult", b =>
{
b.HasOne("LiveRecorder.Domain.Entities.RecordTask", "RecordTask")
.WithOne("Result")
.HasForeignKey("LiveRecorder.Domain.Entities.RecordResult", "RecordTaskId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RecordTask");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordSession", b =>
{
b.HasOne("LiveRecorder.Domain.Entities.LiveRoom", "LiveRoom")
.WithMany()
.HasForeignKey("LiveRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LiveRoom");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordTask", b =>
{
b.HasOne("LiveRecorder.Domain.Entities.LiveRoom", "LiveRoom")
.WithMany("RecordTasks")
.HasForeignKey("LiveRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LiveRecorder.Domain.Entities.RecordSession", "RecordSession")
.WithMany("RecordTasks")
.HasForeignKey("RecordSessionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LiveRoom");
b.Navigation("RecordSession");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.UserSession", b =>
{
b.HasOne("LiveRecorder.Domain.Entities.UserAccount", "UserAccount")
.WithMany()
.HasForeignKey("UserAccountId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserAccount");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.LiveRoom", b =>
{
b.Navigation("RecordTasks");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordSession", b =>
{
b.Navigation("RecordTasks");
});
modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordTask", b =>
{
b.Navigation("Result");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LiveRecorder.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class WidenLargeTextColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Detail",
table: "SystemLogEntries",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(4000)",
oldMaxLength: 4000,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Value",
table: "AppSettings",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(4000)",
oldMaxLength: 4000);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Detail",
table: "SystemLogEntries",
type: "character varying(4000)",
maxLength: 4000,
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Value",
table: "AppSettings",
type: "character varying(4000)",
maxLength: 4000,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
}
}
}
@@ -38,8 +38,7 @@ namespace LiveRecorder.Infrastructure.Persistence.Migrations
b.Property<string>("Value")
.IsRequired()
.HasMaxLength(4000)
.HasColumnType("character varying(4000)");
.HasColumnType("text");
b.HasKey("Id");
@@ -412,8 +411,7 @@ namespace LiveRecorder.Infrastructure.Persistence.Migrations
.HasColumnType("timestamp with time zone");
b.Property<string>("Detail")
.HasMaxLength(4000)
.HasColumnType("character varying(4000)");
.HasColumnType("text");
b.Property<int>("Level")
.HasColumnType("integer");