🗃️ Remove some unused outdated fields

This commit is contained in:
2025-10-26 02:41:30 +08:00
parent 323fa8ee15
commit bf1c8e0a85
7 changed files with 2014 additions and 41 deletions

View File

@@ -4,11 +4,7 @@ using DysonNetwork.Shared.Models;
namespace DysonNetwork.Develop.Project;
public class DevProjectService(
AppDatabase db,
FileReferenceService.FileReferenceServiceClient fileRefs,
FileService.FileServiceClient files
)
public class DevProjectService(AppDatabase db )
{
public async Task<SnDevProject> CreateProjectAsync(
SnDeveloper developer,
@@ -25,14 +21,14 @@ public class DevProjectService(
db.DevProjects.Add(project);
await db.SaveChangesAsync();
return project;
}
public async Task<SnDevProject?> GetProjectAsync(Guid id, Guid? developerId = null)
{
var query = db.DevProjects.AsQueryable();
if (developerId.HasValue)
{
query = query.Where(p => p.DeveloperId == developerId.Value);
@@ -74,4 +70,4 @@ public class DevProjectService(
await db.SaveChangesAsync();
return true;
}
}
}

View File

@@ -19,9 +19,6 @@ public class SnActivity : ModelBase
public object? Data { get; set; }
// Outdated fields, for backward compability
public int Visibility => 0;
public static SnActivity Empty()
{
var now = SystemClock.Instance.GetCurrentInstant();

View File

@@ -20,10 +20,6 @@ public class SnChatRoom : ModelBase, IIdentifiedResource
public bool IsCommunity { get; set; }
public bool IsPublic { get; set; }
// Outdated fields, for backward compability
[MaxLength(32)] public string? PictureId { get; set; }
[MaxLength(32)] public string? BackgroundId { get; set; }
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; }
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; }

View File

@@ -22,10 +22,6 @@ public class SnPublisher : ModelBase, IIdentifiedResource
[MaxLength(256)] public string Nick { get; set; } = string.Empty;
[MaxLength(4096)] public string? Bio { get; set; }
// Outdated fields, for backward compability
[MaxLength(32)] public string? PictureId { get; set; }
[MaxLength(32)] public string? BackgroundId { get; set; }
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; }
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class RemoveOutdatedFileIds : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "background_id",
table: "publishers");
migrationBuilder.DropColumn(
name: "picture_id",
table: "publishers");
migrationBuilder.DropColumn(
name: "background_id",
table: "chat_rooms");
migrationBuilder.DropColumn(
name: "picture_id",
table: "chat_rooms");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "background_id",
table: "publishers",
type: "character varying(32)",
maxLength: 32,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "picture_id",
table: "publishers",
type: "character varying(32)",
maxLength: 32,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "background_id",
table: "chat_rooms",
type: "character varying(32)",
maxLength: 32,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "picture_id",
table: "chat_rooms",
type: "character varying(32)",
maxLength: 32,
nullable: true);
}
}
}

View File

@@ -23,7 +23,7 @@ namespace DysonNetwork.Sphere.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("ProductVersion", "9.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -252,11 +252,6 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("jsonb")
.HasColumnName("background");
b.Property<string>("BackgroundId")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
@@ -287,11 +282,6 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("jsonb")
.HasColumnName("picture");
b.Property<string>("PictureId")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<Guid?>("RealmId")
.HasColumnType("uuid")
.HasColumnName("realm_id");
@@ -920,11 +910,6 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("jsonb")
.HasColumnName("background");
b.Property<string>("BackgroundId")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<string>("Bio")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
@@ -954,11 +939,6 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("jsonb")
.HasColumnName("picture");
b.Property<string>("PictureId")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<Guid?>("RealmId")
.HasColumnType("uuid")
.HasColumnName("realm_id");
@@ -1704,7 +1684,7 @@ namespace DysonNetwork.Sphere.Migrations
modelBuilder.Entity("DysonNetwork.Shared.Models.SnPostFeaturedRecord", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnPost", "Post")
.WithMany()
.WithMany("FeaturedRecords")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
@@ -1924,6 +1904,8 @@ namespace DysonNetwork.Sphere.Migrations
{
b.Navigation("Awards");
b.Navigation("FeaturedRecords");
b.Navigation("Reactions");
});