🗃️ Merge migrations in sphere

This commit is contained in:
2026-01-01 14:05:21 +08:00
parent c28d7bedd7
commit 466a52ecd9
18 changed files with 263 additions and 21438 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,350 +0,0 @@
using System;
using System.Collections.Generic;
using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddActivityPub : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Dictionary<string, object>>(
name: "meta",
table: "publishers",
type: "jsonb",
nullable: true);
migrationBuilder.CreateTable(
name: "fediverse_instances",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
domain = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
name = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
software = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
version = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
is_blocked = table.Column<bool>(type: "boolean", nullable: false),
is_silenced = table.Column<bool>(type: "boolean", nullable: false),
block_reason = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
last_fetched_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
last_activity_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
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_fediverse_instances", x => x.id);
});
migrationBuilder.CreateTable(
name: "fediverse_actors",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
username = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
display_name = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
bio = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
inbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
outbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
followers_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
following_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
featured_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
public_key_id = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
public_key = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
avatar_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
header_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
is_bot = table.Column<bool>(type: "boolean", nullable: false),
is_locked = table.Column<bool>(type: "boolean", nullable: false),
is_discoverable = table.Column<bool>(type: "boolean", nullable: false),
instance_id = table.Column<Guid>(type: "uuid", nullable: false),
last_fetched_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
last_activity_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
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_fediverse_actors", x => x.id);
table.ForeignKey(
name: "fk_fediverse_actors_fediverse_instances_instance_id",
column: x => x.instance_id,
principalTable: "fediverse_instances",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_contents",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
type = table.Column<int>(type: "integer", nullable: false),
title = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
summary = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
content = table.Column<string>(type: "text", nullable: true),
content_html = table.Column<string>(type: "text", nullable: true),
language = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
in_reply_to = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
announced_content_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
published_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
edited_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
is_sensitive = table.Column<bool>(type: "boolean", nullable: false),
// attachments = table.Column<List<ContentAttachment>>(type: "jsonb", nullable: true),
// mentions = table.Column<List<ContentMention>>(type: "jsonb", nullable: true),
// tags = table.Column<List<ContentTag>>(type: "jsonb", nullable: true),
// emojis = table.Column<List<ContentEmoji>>(type: "jsonb", nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
instance_id = table.Column<Guid>(type: "uuid", nullable: false),
reply_count = table.Column<int>(type: "integer", nullable: false),
boost_count = table.Column<int>(type: "integer", nullable: false),
like_count = table.Column<int>(type: "integer", nullable: false),
local_post_id = table.Column<Guid>(type: "uuid", nullable: true),
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_fediverse_contents", x => x.id);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_instances_instance_id",
column: x => x.instance_id,
principalTable: "fediverse_instances",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_relationships",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
target_actor_id = table.Column<Guid>(type: "uuid", nullable: false),
state = table.Column<int>(type: "integer", nullable: false),
is_following = table.Column<bool>(type: "boolean", nullable: false),
is_followed_by = table.Column<bool>(type: "boolean", nullable: false),
is_muting = table.Column<bool>(type: "boolean", nullable: false),
is_blocking = table.Column<bool>(type: "boolean", nullable: false),
followed_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
followed_back_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
reject_reason = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
is_local_actor = table.Column<bool>(type: "boolean", nullable: false),
local_account_id = table.Column<Guid>(type: "uuid", nullable: true),
local_publisher_id = table.Column<Guid>(type: "uuid", nullable: true),
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_fediverse_relationships", x => x.id);
table.ForeignKey(
name: "fk_fediverse_relationships_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_relationships_fediverse_actors_target_actor_id",
column: x => x.target_actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_activities",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
type = table.Column<int>(type: "integer", nullable: false),
object_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
target_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
published_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
is_local = table.Column<bool>(type: "boolean", nullable: false),
raw_data = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
content_id = table.Column<Guid>(type: "uuid", nullable: true),
target_actor_id = table.Column<Guid>(type: "uuid", nullable: true),
local_post_id = table.Column<Guid>(type: "uuid", nullable: true),
local_account_id = table.Column<Guid>(type: "uuid", nullable: true),
status = table.Column<int>(type: "integer", nullable: false),
error_message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
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_fediverse_activities", x => x.id);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_target_actor_id",
column: x => x.target_actor_id,
principalTable: "fediverse_actors",
principalColumn: "id");
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_reactions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
type = table.Column<int>(type: "integer", nullable: false),
emoji = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
is_local = table.Column<bool>(type: "boolean", nullable: false),
content_id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
local_account_id = table.Column<Guid>(type: "uuid", nullable: true),
local_reaction_id = table.Column<Guid>(type: "uuid", nullable: true),
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_fediverse_reactions", x => x.id);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_actor_id",
table: "fediverse_activities",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_content_id",
table: "fediverse_activities",
column: "content_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_target_actor_id",
table: "fediverse_activities",
column: "target_actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_actors_instance_id",
table: "fediverse_actors",
column: "instance_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_actors_uri",
table: "fediverse_actors",
column: "uri",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_actor_id",
table: "fediverse_contents",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_instance_id",
table: "fediverse_contents",
column: "instance_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_uri",
table: "fediverse_contents",
column: "uri",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_instances_domain",
table: "fediverse_instances",
column: "domain",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_actor_id",
table: "fediverse_reactions",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_content_id",
table: "fediverse_reactions",
column: "content_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_relationships_actor_id",
table: "fediverse_relationships",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_relationships_target_actor_id",
table: "fediverse_relationships",
column: "target_actor_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "fediverse_activities");
migrationBuilder.DropTable(
name: "fediverse_reactions");
migrationBuilder.DropTable(
name: "fediverse_relationships");
migrationBuilder.DropTable(
name: "fediverse_contents");
migrationBuilder.DropTable(
name: "fediverse_actors");
migrationBuilder.DropTable(
name: "fediverse_instances");
migrationBuilder.DropColumn(
name: "meta",
table: "publishers");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddSeprateActorType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "type",
table: "fediverse_actors",
type: "character varying(2048)",
maxLength: 2048,
nullable: false,
defaultValue: "Person");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "type",
table: "fediverse_actors");
}
}
}

View File

@@ -1,83 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class EnrichFediverseInstance : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "active_users",
table: "fediverse_instances",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "contact_account_username",
table: "fediverse_instances",
type: "character varying(256)",
maxLength: 256,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "contact_email",
table: "fediverse_instances",
type: "character varying(512)",
maxLength: 512,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "icon_url",
table: "fediverse_instances",
type: "character varying(2048)",
maxLength: 2048,
nullable: true);
migrationBuilder.AddColumn<Instant>(
name: "metadata_fetched_at",
table: "fediverse_instances",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "thumbnail_url",
table: "fediverse_instances",
type: "character varying(2048)",
maxLength: 2048,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "active_users",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "contact_account_username",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "contact_email",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "icon_url",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "metadata_fetched_at",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "thumbnail_url",
table: "fediverse_instances");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,60 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class BetterLocalActor : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_local_actor",
table: "fediverse_relationships");
migrationBuilder.DropColumn(
name: "local_account_id",
table: "fediverse_relationships");
migrationBuilder.DropColumn(
name: "local_publisher_id",
table: "fediverse_relationships");
migrationBuilder.AddColumn<Guid>(
name: "publisher_id",
table: "fediverse_actors",
type: "uuid",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "publisher_id",
table: "fediverse_actors");
migrationBuilder.AddColumn<bool>(
name: "is_local_actor",
table: "fediverse_relationships",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<Guid>(
name: "local_account_id",
table: "fediverse_relationships",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "local_publisher_id",
table: "fediverse_relationships",
type: "uuid",
nullable: true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class RemoveFollowingBooleanInFediverse : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_followed_by",
table: "fediverse_relationships");
migrationBuilder.DropColumn(
name: "is_following",
table: "fediverse_relationships");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "is_followed_by",
table: "fediverse_relationships",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "is_following",
table: "fediverse_relationships",
type: "boolean",
nullable: false,
defaultValue: false);
}
}
}

View File

@@ -1,29 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class RemoveSeprateLikeCountOnPost : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "like_count",
table: "posts");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "like_count",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
}
}
}

View File

@@ -1,48 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddActivityPubDelivery : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "activity_pub_deliveries",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
activity_id = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
activity_type = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
inbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
actor_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
status = table.Column<int>(type: "integer", nullable: false),
retry_count = table.Column<int>(type: "integer", nullable: false),
error_message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
last_attempt_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
next_retry_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
sent_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
response_status_code = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
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_activity_pub_deliveries", x => x.id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "activity_pub_deliveries");
}
}
}

View File

@@ -17,8 +17,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DysonNetwork.Sphere.Migrations
{
[DbContext(typeof(AppDatabase))]
[Migration("20251231163256_AddActivityPubDelivery")]
partial class AddActivityPubDelivery
[Migration("20260101135529_AddActivityPub")]
partial class AddActivityPub
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore.Migrations;
@@ -9,23 +9,162 @@ using NodaTime;
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class MergeFediverseDataClass : Migration
public partial class AddActivityPub : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_posts_publishers_publisher_id",
table: "posts");
migrationBuilder.AddColumn<Dictionary<string, object>>(
name: "meta",
table: "publishers",
type: "jsonb",
nullable: true);
migrationBuilder.DropTable(
name: "fediverse_activities");
migrationBuilder.AddColumn<string>(
name: "private_key_pem",
table: "publishers",
type: "character varying(8192)",
maxLength: 8192,
nullable: true);
migrationBuilder.DropTable(
name: "fediverse_reactions");
migrationBuilder.AddColumn<string>(
name: "public_key_pem",
table: "publishers",
type: "character varying(8192)",
maxLength: 8192,
nullable: true);
migrationBuilder.DropTable(
name: "fediverse_contents");
migrationBuilder.CreateTable(
name: "fediverse_instances",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
domain = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
name = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
software = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
version = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
is_blocked = table.Column<bool>(type: "boolean", nullable: false),
is_silenced = table.Column<bool>(type: "boolean", nullable: false),
block_reason = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
last_fetched_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
last_activity_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
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),
active_users = table.Column<int>(type: "integer", nullable: true),
contact_account_username = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
contact_email = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
icon_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
metadata_fetched_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
thumbnail_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_instances", x => x.id);
});
migrationBuilder.CreateTable(
name: "fediverse_actors",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
username = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
display_name = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
bio = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
inbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
outbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
followers_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
following_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
featured_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
public_key_id = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
public_key = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
avatar_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
header_url = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
is_bot = table.Column<bool>(type: "boolean", nullable: false),
is_locked = table.Column<bool>(type: "boolean", nullable: false),
is_discoverable = table.Column<bool>(type: "boolean", nullable: false),
instance_id = table.Column<Guid>(type: "uuid", nullable: false),
last_fetched_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
last_activity_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
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),
type = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false, defaultValue: "Person"),
publisher_id = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_actors", x => x.id);
table.ForeignKey(
name: "fk_fediverse_actors_fediverse_instances_instance_id",
column: x => x.instance_id,
principalTable: "fediverse_instances",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_relationships",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
target_actor_id = table.Column<Guid>(type: "uuid", nullable: false),
state = table.Column<int>(type: "integer", nullable: false),
is_muting = table.Column<bool>(type: "boolean", nullable: false),
is_blocking = table.Column<bool>(type: "boolean", nullable: false),
followed_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
followed_back_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
reject_reason = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
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_fediverse_relationships", x => x.id);
table.ForeignKey(
name: "fk_fediverse_relationships_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_relationships_fediverse_actors_target_actor_id",
column: x => x.target_actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "activity_pub_deliveries",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
activity_id = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
activity_type = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
inbox_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
actor_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
status = table.Column<int>(type: "integer", nullable: false),
retry_count = table.Column<int>(type: "integer", nullable: false),
error_message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
last_attempt_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
next_retry_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
sent_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
response_status_code = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
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_activity_pub_deliveries", x => x.id);
});
migrationBuilder.RenameColumn(
name: "meta",
@@ -80,13 +219,6 @@ namespace DysonNetwork.Sphere.Migrations
maxLength: 2048,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "like_count",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<List<ContentMention>>(
name: "mentions",
table: "posts",
@@ -128,6 +260,33 @@ namespace DysonNetwork.Sphere.Migrations
nullable: false,
defaultValue: false);
migrationBuilder.CreateIndex(
name: "ix_fediverse_actors_instance_id",
table: "fediverse_actors",
column: "instance_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_actors_uri",
table: "fediverse_actors",
column: "uri",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_instances_domain",
table: "fediverse_instances",
column: "domain",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_relationships_actor_id",
table: "fediverse_relationships",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_relationships_target_actor_id",
table: "fediverse_relationships",
column: "target_actor_id");
migrationBuilder.CreateIndex(
name: "ix_posts_actor_id",
table: "posts",
@@ -157,7 +316,8 @@ namespace DysonNetwork.Sphere.Migrations
table: "posts",
column: "publisher_id",
principalTable: "publishers",
principalColumn: "id");
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
@@ -183,68 +343,37 @@ namespace DysonNetwork.Sphere.Migrations
name: "ix_post_reactions_actor_id",
table: "post_reactions");
migrationBuilder.DropColumn(
name: "actor_id",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_fediverse_relationships_target_actor_id",
table: "fediverse_relationships");
migrationBuilder.DropColumn(
name: "boost_count",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_fediverse_relationships_actor_id",
table: "fediverse_relationships");
migrationBuilder.DropColumn(
name: "content_type",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_fediverse_instances_domain",
table: "fediverse_instances");
migrationBuilder.DropColumn(
name: "fediverse_type",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_fediverse_actors_uri",
table: "fediverse_actors");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "posts");
migrationBuilder.DropColumn(
name: "language",
table: "posts");
migrationBuilder.DropColumn(
name: "like_count",
table: "posts");
migrationBuilder.DropColumn(
name: "mentions",
table: "posts");
migrationBuilder.DropColumn(
name: "replies_count",
table: "posts");
migrationBuilder.DropColumn(
name: "actor_id",
table: "post_reactions");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "post_reactions");
migrationBuilder.DropIndex(
name: "ix_fediverse_actors_instance_id",
table: "fediverse_actors");
migrationBuilder.DropColumn(
name: "is_local",
table: "post_reactions");
migrationBuilder.RenameColumn(
name: "metadata",
table: "posts",
newName: "meta");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "post_reactions");
migrationBuilder.AlterColumn<Guid>(
name: "publisher_id",
table: "posts",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.DropColumn(
name: "actor_id",
table: "post_reactions");
migrationBuilder.AlterColumn<Guid>(
name: "account_id",
@@ -256,178 +385,76 @@ namespace DysonNetwork.Sphere.Migrations
oldType: "uuid",
oldNullable: true);
migrationBuilder.CreateTable(
name: "fediverse_contents",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
instance_id = table.Column<Guid>(type: "uuid", nullable: false),
announced_content_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
boost_count = table.Column<int>(type: "integer", nullable: false),
content = table.Column<string>(type: "text", nullable: true),
content_html = table.Column<string>(type: "text", nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
edited_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
in_reply_to = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
is_sensitive = table.Column<bool>(type: "boolean", nullable: false),
language = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
like_count = table.Column<int>(type: "integer", nullable: false),
local_post_id = table.Column<Guid>(type: "uuid", nullable: true),
metadata = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
published_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
reply_count = table.Column<int>(type: "integer", nullable: false),
summary = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
title = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
type = table.Column<int>(type: "integer", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_contents", x => x.id);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_instances_instance_id",
column: x => x.instance_id,
principalTable: "fediverse_instances",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.DropColumn(
name: "replies_count",
table: "posts");
migrationBuilder.CreateTable(
name: "fediverse_activities",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
content_id = table.Column<Guid>(type: "uuid", nullable: true),
target_actor_id = table.Column<Guid>(type: "uuid", nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
error_message = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
is_local = table.Column<bool>(type: "boolean", nullable: false),
local_account_id = table.Column<Guid>(type: "uuid", nullable: true),
local_post_id = table.Column<Guid>(type: "uuid", nullable: true),
object_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
published_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
raw_data = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
status = table.Column<int>(type: "integer", nullable: false),
target_uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
type = table.Column<int>(type: "integer", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_activities", x => x.id);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_target_actor_id",
column: x => x.target_actor_id,
principalTable: "fediverse_actors",
principalColumn: "id");
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.DropColumn(
name: "mentions",
table: "posts");
migrationBuilder.CreateTable(
name: "fediverse_reactions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
actor_id = table.Column<Guid>(type: "uuid", nullable: false),
content_id = table.Column<Guid>(type: "uuid", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
emoji = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
is_local = table.Column<bool>(type: "boolean", nullable: false),
local_account_id = table.Column<Guid>(type: "uuid", nullable: true),
local_reaction_id = table.Column<Guid>(type: "uuid", nullable: true),
type = table.Column<int>(type: "integer", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
uri = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_reactions", x => x.id);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.DropColumn(
name: "language",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_actor_id",
table: "fediverse_activities",
column: "actor_id");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_content_id",
table: "fediverse_activities",
column: "content_id");
migrationBuilder.DropColumn(
name: "fediverse_type",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_target_actor_id",
table: "fediverse_activities",
column: "target_actor_id");
migrationBuilder.DropColumn(
name: "content_type",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_actor_id",
table: "fediverse_contents",
column: "actor_id");
migrationBuilder.DropColumn(
name: "boost_count",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_instance_id",
table: "fediverse_contents",
column: "instance_id");
migrationBuilder.DropColumn(
name: "actor_id",
table: "posts");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_uri",
table: "fediverse_contents",
column: "uri",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_actor_id",
table: "fediverse_reactions",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_content_id",
table: "fediverse_reactions",
column: "content_id");
migrationBuilder.AddForeignKey(
name: "fk_posts_publishers_publisher_id",
migrationBuilder.AlterColumn<Guid>(
name: "publisher_id",
table: "posts",
column: "publisher_id",
principalTable: "publishers",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.RenameColumn(
name: "metadata",
table: "posts",
newName: "meta");
migrationBuilder.DropTable(
name: "activity_pub_deliveries");
migrationBuilder.DropTable(
name: "fediverse_relationships");
migrationBuilder.DropTable(
name: "fediverse_actors");
migrationBuilder.DropTable(
name: "fediverse_instances");
migrationBuilder.DropColumn(
name: "public_key_pem",
table: "publishers");
migrationBuilder.DropColumn(
name: "private_key_pem",
table: "publishers");
migrationBuilder.DropColumn(
name: "meta",
table: "publishers");
}
}
}