File compression duplicate

This commit is contained in:
2025-05-01 19:19:58 +08:00
parent 0f9e865c0b
commit b1543f5b08
16 changed files with 185 additions and 1798 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class UnableToNamingThing1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "has_compression",
table: "files",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "activities",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
type = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
resource_identifier = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
visibility = table.Column<int>(type: "integer", nullable: false),
account_id = table.Column<long>(type: "bigint", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_activities", x => x.id);
table.ForeignKey(
name: "fk_activities_accounts_account_id",
column: x => x.account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_activities_account_id",
table: "activities",
column: "account_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "activities");
migrationBuilder.DropColumn(
name: "has_compression",
table: "files");
}
}
}

View File

@ -9,14 +9,15 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
[DbContext(typeof(AppDatabase))]
[Migration("20250501072931_UnableToNamingThing1")]
partial class UnableToNamingThing1
[Migration("20250501080049_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -790,8 +791,8 @@ namespace DysonNetwork.Sphere.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("Content")
.HasColumnType("text")
b.Property<JsonDocument>("Content")
.HasColumnType("jsonb")
.HasColumnName("content");
b.Property<Instant>("CreatedAt")
@ -840,6 +841,14 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("bigint")
.HasColumnName("replied_post_id");
b.Property<NpgsqlTsVector>("SearchVector")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasColumnName("search_vector")
.HasAnnotation("Npgsql:TsVectorConfig", "simple")
.HasAnnotation("Npgsql:TsVectorProperties", new[] { "Title", "Description", "Content" });
b.Property<long?>("ThreadedPostId")
.HasColumnType("bigint")
.HasColumnName("threaded_post_id");
@ -885,6 +894,11 @@ namespace DysonNetwork.Sphere.Migrations
b.HasIndex("RepliedPostId")
.HasDatabaseName("ix_posts_replied_post_id");
b.HasIndex("SearchVector")
.HasDatabaseName("ix_posts_search_vector");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchVector"), "GIN");
b.HasIndex("ThreadedPostId")
.IsUnique()
.HasDatabaseName("ix_posts_threaded_post_id");

View File

@ -4,6 +4,7 @@ using System.Text.Json;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
@ -162,6 +163,30 @@ namespace DysonNetwork.Sphere.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "activities",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
type = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
resource_identifier = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
visibility = table.Column<int>(type: "integer", nullable: false),
account_id = table.Column<long>(type: "bigint", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_activities", x => x.id);
table.ForeignKey(
name: "fk_activities_accounts_account_id",
column: x => x.account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "auth_challenges",
columns: table => new
@ -395,6 +420,7 @@ namespace DysonNetwork.Sphere.Migrations
uploaded_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
expired_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
uploaded_to = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
has_compression = table.Column<bool>(type: "boolean", nullable: false),
used_count = table.Column<int>(type: "integer", nullable: false),
account_id = table.Column<long>(type: "bigint", nullable: false),
post_id = table.Column<long>(type: "bigint", nullable: true),
@ -487,7 +513,7 @@ namespace DysonNetwork.Sphere.Migrations
edited_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
published_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
visibility = table.Column<int>(type: "integer", nullable: false),
content = table.Column<string>(type: "text", nullable: true),
content = table.Column<JsonDocument>(type: "jsonb", nullable: true),
type = table.Column<int>(type: "integer", nullable: false),
meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
views_unique = table.Column<int>(type: "integer", nullable: false),
@ -497,6 +523,9 @@ namespace DysonNetwork.Sphere.Migrations
threaded_post_id = table.Column<long>(type: "bigint", nullable: true),
replied_post_id = table.Column<long>(type: "bigint", nullable: true),
forwarded_post_id = table.Column<long>(type: "bigint", nullable: true),
search_vector = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false)
.Annotation("Npgsql:TsVectorConfig", "simple")
.Annotation("Npgsql:TsVectorProperties", new[] { "title", "description", "content" }),
publisher_id = table.Column<long>(type: "bigint", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
@ -693,6 +722,11 @@ namespace DysonNetwork.Sphere.Migrations
column: "name",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_activities_account_id",
table: "activities",
column: "account_id");
migrationBuilder.CreateIndex(
name: "ix_auth_challenges_account_id",
table: "auth_challenges",
@ -806,6 +840,12 @@ namespace DysonNetwork.Sphere.Migrations
table: "posts",
column: "replied_post_id");
migrationBuilder.CreateIndex(
name: "ix_posts_search_vector",
table: "posts",
column: "search_vector")
.Annotation("Npgsql:IndexMethod", "GIN");
migrationBuilder.CreateIndex(
name: "ix_posts_threaded_post_id",
table: "posts",
@ -891,6 +931,9 @@ namespace DysonNetwork.Sphere.Migrations
migrationBuilder.DropTable(
name: "account_relationships");
migrationBuilder.DropTable(
name: "activities");
migrationBuilder.DropTable(
name: "auth_sessions");

View File

@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
@ -787,8 +788,8 @@ namespace DysonNetwork.Sphere.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("Content")
.HasColumnType("text")
b.Property<JsonDocument>("Content")
.HasColumnType("jsonb")
.HasColumnName("content");
b.Property<Instant>("CreatedAt")
@ -837,6 +838,14 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("bigint")
.HasColumnName("replied_post_id");
b.Property<NpgsqlTsVector>("SearchVector")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasColumnName("search_vector")
.HasAnnotation("Npgsql:TsVectorConfig", "simple")
.HasAnnotation("Npgsql:TsVectorProperties", new[] { "Title", "Description", "Content" });
b.Property<long?>("ThreadedPostId")
.HasColumnType("bigint")
.HasColumnName("threaded_post_id");
@ -882,6 +891,11 @@ namespace DysonNetwork.Sphere.Migrations
b.HasIndex("RepliedPostId")
.HasDatabaseName("ix_posts_replied_post_id");
b.HasIndex("SearchVector")
.HasDatabaseName("ix_posts_search_vector");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchVector"), "GIN");
b.HasIndex("ThreadedPostId")
.IsUnique()
.HasDatabaseName("ix_posts_threaded_post_id");