107 lines
4.7 KiB
C#
107 lines
4.7 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace AAIntegration.SimmonsBank.API.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class RemovedUnneededEntities : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Transactions");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Accounts");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Accounts",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
OwnerId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Balance = table.Column<decimal>(type: "numeric", nullable: false),
|
|||
|
ExternalAccountNumber = table.Column<string>(type: "text", nullable: false),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Accounts", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Accounts_Users_OwnerId",
|
|||
|
column: x => x.OwnerId,
|
|||
|
principalTable: "Users",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Transactions",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
CreditAccountId = table.Column<int>(type: "integer", nullable: true),
|
|||
|
DebitAccountId = table.Column<int>(type: "integer", nullable: true),
|
|||
|
OwnerId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Amount = table.Column<decimal>(type: "numeric", nullable: false),
|
|||
|
CreatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
Description = table.Column<string>(type: "text", nullable: false),
|
|||
|
ExternalId = table.Column<string>(type: "text", nullable: false),
|
|||
|
IsPending = table.Column<bool>(type: "boolean", nullable: false),
|
|||
|
UpdatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Transactions", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Transactions_Accounts_CreditAccountId",
|
|||
|
column: x => x.CreditAccountId,
|
|||
|
principalTable: "Accounts",
|
|||
|
principalColumn: "Id");
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Transactions_Accounts_DebitAccountId",
|
|||
|
column: x => x.DebitAccountId,
|
|||
|
principalTable: "Accounts",
|
|||
|
principalColumn: "Id");
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Transactions_Users_OwnerId",
|
|||
|
column: x => x.OwnerId,
|
|||
|
principalTable: "Users",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Accounts_OwnerId",
|
|||
|
table: "Accounts",
|
|||
|
column: "OwnerId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Transactions_CreditAccountId",
|
|||
|
table: "Transactions",
|
|||
|
column: "CreditAccountId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Transactions_DebitAccountId",
|
|||
|
table: "Transactions",
|
|||
|
column: "DebitAccountId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Transactions_OwnerId",
|
|||
|
table: "Transactions",
|
|||
|
column: "OwnerId");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|