From 24b901dddd071942aaae5fea4a2c48bc8aa32f4d Mon Sep 17 00:00:00 2001 From: nanxun Date: Wed, 29 Apr 2026 23:54:50 +0800 Subject: [PATCH] fix: widen postgres text columns for migration --- .../Persistence/LiveRecorderDbContext.cs | 2 - ...29153158_WidenLargeTextColumns.Designer.cs | 582 ++++++++++++++++++ .../20260429153158_WidenLargeTextColumns.cs | 56 ++ .../LiveRecorderDbContextModelSnapshot.cs | 6 +- 4 files changed, 640 insertions(+), 6 deletions(-) create mode 100644 src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.Designer.cs create mode 100644 src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.cs diff --git a/src/LiveRecorder.Infrastructure/Persistence/LiveRecorderDbContext.cs b/src/LiveRecorder.Infrastructure/Persistence/LiveRecorderDbContext.cs index 421b17a..02f0fb3 100644 --- a/src/LiveRecorder.Infrastructure/Persistence/LiveRecorderDbContext.cs +++ b/src/LiveRecorder.Infrastructure/Persistence/LiveRecorderDbContext.cs @@ -124,7 +124,6 @@ public sealed class LiveRecorderDbContext : DbContext, IUnitOfWork builder.Property(static x => x.Level).HasConversion(); 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(); }); diff --git a/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.Designer.cs b/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.Designer.cs new file mode 100644 index 0000000..78e724e --- /dev/null +++ b/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.Designer.cs @@ -0,0 +1,582 @@ +// +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 + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Alias") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AnchorId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AnchorName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AvailabilityStatus") + .HasColumnType("integer"); + + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("CoverUrl") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DanmakuIncludeNonChatEventsOverride") + .HasColumnType("boolean"); + + b.Property("DanmakuMinPollIntervalMillisecondsOverride") + .HasColumnType("integer"); + + b.Property("DanmakuRetryDelayMaxSecondsOverride") + .HasColumnType("integer"); + + b.Property("EnableAutoReconnectOverride") + .HasColumnType("boolean"); + + b.Property("EnableDanmakuRecordingOverride") + .HasColumnType("boolean"); + + b.Property("HasSentLiveNotificationForCurrentSession") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsPinned") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsPriority") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("LastAutoStartDecisionAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastAutoStartDecisionCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("LastAutoStartDecisionDetail") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("LastAutoStartDecisionSummary") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("LastCheckedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LastStartRecordingTriggeredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("OutputFormatOverride") + .HasColumnType("integer"); + + b.Property("Platform") + .HasColumnType("integer"); + + b.Property("PollingIntervalSecondsOverride") + .HasColumnType("integer"); + + b.Property("PreferredQualityOverride") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ReadWriteTimeoutMillisecondsOverride") + .HasColumnType("integer"); + + b.Property("ReconnectDelayMaxSecondsOverride") + .HasColumnType("integer"); + + b.Property("RecordingTemplateOverride") + .HasColumnType("integer"); + + b.Property("Remark") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("RoomId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("SaveModeOverride") + .HasColumnType("integer"); + + b.Property("SegmentDurationMinutesOverride") + .HasColumnType("integer"); + + b.Property("SourceUrl") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("Title") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DanmakuFilePath") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("DanmakuMessageCount") + .HasColumnType("integer"); + + b.Property("DeletedLocalFilesAfterUpload") + .HasColumnType("boolean"); + + b.Property("DurationSeconds") + .HasColumnType("double precision"); + + b.Property("ErrorMessage") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("FileSizeBytes") + .HasColumnType("bigint"); + + b.Property("FinalStatus") + .HasColumnType("integer"); + + b.Property("LastUploadProvider") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("LastUploadedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RecordTaskId") + .HasColumnType("uuid"); + + b.Property("RemoteDanmakuPath") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("RemoteVideoPath") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("UploadErrorMessage") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("UploadStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RecordTaskId") + .IsUnique(); + + b.ToTable("RecordResults", (string)null); + }); + + modelBuilder.Entity("LiveRecorder.Domain.Entities.RecordSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActiveSegmentIndex") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ErrorMessage") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("LiveRoomId") + .HasColumnType("uuid"); + + b.Property("OutputFormat") + .HasColumnType("integer"); + + b.Property("OutputPathPattern") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("PreferredQuality") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RecorderProcessId") + .HasColumnType("integer"); + + b.Property("SaveMode") + .HasColumnType("integer"); + + b.Property("SegmentCount") + .HasColumnType("integer"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StreamUrl") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DurationSeconds") + .HasColumnType("double precision"); + + b.Property("EndedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ErrorMessage") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("LiveRoomId") + .HasColumnType("uuid"); + + b.Property("OutputFilePath") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("OutputFormat") + .HasColumnType("integer"); + + b.Property("PreferredQuality") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RecordSessionId") + .HasColumnType("uuid"); + + b.Property("RecorderProcessId") + .HasColumnType("integer"); + + b.Property("SegmentIndex") + .HasColumnType("integer"); + + b.Property("StartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StreamUrl") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Detail") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LiveRoomId") + .HasColumnType("uuid"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("RecordSessionId") + .HasColumnType("uuid"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("PasswordHash") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RevokedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Token") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("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 + } + } +} diff --git a/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.cs b/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.cs new file mode 100644 index 0000000..091f0de --- /dev/null +++ b/src/LiveRecorder.Infrastructure/Persistence/Migrations/20260429153158_WidenLargeTextColumns.cs @@ -0,0 +1,56 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LiveRecorder.Infrastructure.Persistence.Migrations +{ + /// + public partial class WidenLargeTextColumns : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Detail", + table: "SystemLogEntries", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(4000)", + oldMaxLength: 4000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Value", + table: "AppSettings", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(4000)", + oldMaxLength: 4000); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Detail", + table: "SystemLogEntries", + type: "character varying(4000)", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Value", + table: "AppSettings", + type: "character varying(4000)", + maxLength: 4000, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + } + } +} diff --git a/src/LiveRecorder.Infrastructure/Persistence/Migrations/LiveRecorderDbContextModelSnapshot.cs b/src/LiveRecorder.Infrastructure/Persistence/Migrations/LiveRecorderDbContextModelSnapshot.cs index 96cf7fd..ecaa0da 100644 --- a/src/LiveRecorder.Infrastructure/Persistence/Migrations/LiveRecorderDbContextModelSnapshot.cs +++ b/src/LiveRecorder.Infrastructure/Persistence/Migrations/LiveRecorderDbContextModelSnapshot.cs @@ -38,8 +38,7 @@ namespace LiveRecorder.Infrastructure.Persistence.Migrations b.Property("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("Detail") - .HasMaxLength(4000) - .HasColumnType("character varying(4000)"); + .HasColumnType("text"); b.Property("Level") .HasColumnType("integer");