🐛 Bug fixes 💄 Optimizations

This commit is contained in:
2025-05-18 20:05:15 +08:00
parent 5b9b28d77a
commit cf9084b8c0
15 changed files with 7314 additions and 60 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,244 @@
using System.Collections.Generic;
using DysonNetwork.Sphere.Storage;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class OptimizeFileStorage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "image_id",
table: "stickers",
type: "character varying(32)",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(128)");
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "realms",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "realms",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "publishers",
type: "character varying(32)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "publishers",
type: "character varying(32)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "id",
table: "files",
type: "character varying(32)",
maxLength: 32,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldMaxLength: 128);
migrationBuilder.AddColumn<List<CloudFileSensitiveMark>>(
name: "sensitive_marks",
table: "files",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "storage_id",
table: "files",
type: "character varying(32)",
maxLength: 32,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "storage_url",
table: "files",
type: "character varying(4096)",
maxLength: 4096,
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "chat_rooms",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "chat_rooms",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "account_profiles",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "account_profiles",
type: "character varying(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "sensitive_marks",
table: "files");
migrationBuilder.DropColumn(
name: "storage_id",
table: "files");
migrationBuilder.DropColumn(
name: "storage_url",
table: "files");
migrationBuilder.AlterColumn<string>(
name: "image_id",
table: "stickers",
type: "character varying(128)",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(32)");
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "realms",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "realms",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "publishers",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "publishers",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "id",
table: "files",
type: "character varying(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "chat_rooms",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "chat_rooms",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "picture_id",
table: "account_profiles",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "background_id",
table: "account_profiles",
type: "character varying(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(32)",
oldMaxLength: 32,
oldNullable: true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class DontKnowHowToNameThing : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "ix_stickers_slug",
table: "stickers",
column: "slug");
migrationBuilder.CreateIndex(
name: "ix_sticker_packs_prefix",
table: "sticker_packs",
column: "prefix",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "ix_stickers_slug",
table: "stickers");
migrationBuilder.DropIndex(
name: "ix_sticker_packs_prefix",
table: "sticker_packs");
}
}
}

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Text.Json;
using DysonNetwork.Sphere;
using DysonNetwork.Sphere.Account;
using DysonNetwork.Sphere.Storage;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -11,7 +12,6 @@ using NetTopologySuite.Geometries;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
using Point = NetTopologySuite.Geometries.Point;
#nullable disable
@ -537,7 +537,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("account_id");
b.Property<string>("BackgroundId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<string>("Bio")
@ -573,7 +574,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("middle_name");
b.Property<string>("PictureId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<Instant>("UpdatedAt")
@ -957,7 +959,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("id");
b.Property<string>("BackgroundId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<Instant>("CreatedAt")
@ -983,7 +986,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("name");
b.Property<string>("PictureId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<Guid?>("RealmId")
@ -1766,7 +1770,7 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("account_id");
b.Property<string>("BackgroundId")
.HasColumnType("character varying(128)")
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<string>("Bio")
@ -1795,7 +1799,7 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("nick");
b.Property<string>("PictureId")
.HasColumnType("character varying(128)")
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<Guid?>("RealmId")
@ -1972,7 +1976,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("account_id");
b.Property<string>("BackgroundId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("background_id");
b.Property<Instant>("CreatedAt")
@ -2004,7 +2009,8 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnName("name");
b.Property<string>("PictureId")
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("picture_id");
b.Property<string>("Slug")
@ -2101,7 +2107,8 @@ namespace DysonNetwork.Sphere.Migrations
b.Property<string>("ImageId")
.IsRequired()
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("image_id");
b.Property<Guid>("PackId")
@ -2127,6 +2134,9 @@ namespace DysonNetwork.Sphere.Migrations
b.HasIndex("PackId")
.HasDatabaseName("ix_stickers_pack_id");
b.HasIndex("Slug")
.HasDatabaseName("ix_stickers_slug");
b.ToTable("stickers", (string)null);
});
@ -2174,6 +2184,10 @@ namespace DysonNetwork.Sphere.Migrations
b.HasKey("Id")
.HasName("pk_sticker_packs");
b.HasIndex("Prefix")
.IsUnique()
.HasDatabaseName("ix_sticker_packs_prefix");
b.HasIndex("PublisherId")
.HasDatabaseName("ix_sticker_packs_publisher_id");
@ -2183,8 +2197,8 @@ namespace DysonNetwork.Sphere.Migrations
modelBuilder.Entity("DysonNetwork.Sphere.Storage.CloudFile", b =>
{
b.Property<string>("Id")
.HasMaxLength(128)
.HasColumnType("character varying(128)")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("id");
b.Property<Guid>("AccountId")
@ -2240,10 +2254,24 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("uuid")
.HasColumnName("post_id");
b.Property<List<CloudFileSensitiveMark>>("SensitiveMarks")
.HasColumnType("jsonb")
.HasColumnName("sensitive_marks");
b.Property<long>("Size")
.HasColumnType("bigint")
.HasColumnName("size");
b.Property<string>("StorageId")
.HasMaxLength(32)
.HasColumnType("character varying(32)")
.HasColumnName("storage_id");
b.Property<string>("StorageUrl")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("storage_url");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");