56 lines
2.3 KiB
C#
56 lines
2.3 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|