Files
fiscalos/src/FiscalOS.Infra/Migrations/20260213130218_AccountAndMetadata.cs
T

93 lines
3.3 KiB
C#
Raw Normal View History

using System;
2026-02-15 07:41:09 -06:00
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FiscalOS.Infra.Migrations
{
2026-02-15 07:41:09 -06:00
/// <inheritdoc />
public partial class AccountAndMetadata : Migration
{
/// <inheritdoc />
2026-02-15 07:41:09 -06:00
protected override void Up(MigrationBuilder migrationBuilder)
{
2026-02-15 07:41:09 -06:00
migrationBuilder.CreateTable(
name: "Account",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
InstituionId = table.Column<Guid>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Account", x => x.Id);
table.ForeignKey(
name: "FK_Account_Institution_InstituionId",
column: x => x.InstituionId,
principalTable: "Institution",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Account_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
2026-02-15 07:41:09 -06:00
migrationBuilder.CreateTable(
name: "AccountMetadata",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Type = table.Column<string>(type: "TEXT", maxLength: 21, nullable: false),
AccountId = table.Column<Guid>(type: "TEXT", nullable: false),
PlaidId = table.Column<string>(type: "TEXT", nullable: true),
PlaidName = table.Column<string>(type: "TEXT", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AccountMetadata", x => x.Id);
table.ForeignKey(
name: "FK_AccountMetadata_Account_AccountId",
column: x => x.AccountId,
principalTable: "Account",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
2026-02-15 07:41:09 -06:00
migrationBuilder.CreateIndex(
name: "IX_Account_InstituionId",
table: "Account",
column: "InstituionId");
2026-02-15 07:41:09 -06:00
migrationBuilder.CreateIndex(
name: "IX_Account_UserId",
table: "Account",
column: "UserId");
2026-02-15 07:41:09 -06:00
migrationBuilder.CreateIndex(
name: "IX_AccountMetadata_AccountId",
table: "AccountMetadata",
column: "AccountId",
unique: true);
}
2026-02-15 07:41:09 -06:00
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AccountMetadata");
migrationBuilder.DropTable(
name: "Account");
}
}
}