🗃️ Add account relationships

This commit is contained in:
2025-04-16 01:16:35 +08:00
parent 701a5d3882
commit cec8c3af81
8 changed files with 764 additions and 15 deletions

View File

@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AddRelationship : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "account_relationships",
columns: table => new
{
from_account_id = table.Column<long>(type: "bigint", nullable: false),
to_account_id = table.Column<long>(type: "bigint", nullable: false),
type = table.Column<int>(type: "integer", 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_account_relationships", x => new { x.from_account_id, x.to_account_id });
table.ForeignKey(
name: "fk_account_relationships_accounts_from_account_id",
column: x => x.from_account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_account_relationships_accounts_to_account_id",
column: x => x.to_account_id,
principalTable: "accounts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_account_relationships_to_account_id",
table: "account_relationships",
column: "to_account_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "account_relationships");
}
}
}