57 lines
2.4 KiB
C#
57 lines
2.4 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
|
|
{
|
|
account_id = table.Column<long>(type: "bigint", nullable: false),
|
|
related_id = table.Column<long>(type: "bigint", nullable: false),
|
|
expired_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
|
|
status = 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.account_id, x.related_id });
|
|
table.ForeignKey(
|
|
name: "fk_account_relationships_accounts_account_id",
|
|
column: x => x.account_id,
|
|
principalTable: "accounts",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "fk_account_relationships_accounts_related_id",
|
|
column: x => x.related_id,
|
|
principalTable: "accounts",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_account_relationships_related_id",
|
|
table: "account_relationships",
|
|
column: "related_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "account_relationships");
|
|
}
|
|
}
|
|
}
|