153 lines
7.1 KiB
C#
153 lines
7.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace AAIntegration.SimmonsBank.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AccountsAllocsOperations : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "CurrencyTypes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Code = table.Column<string>(type: "text", nullable: false),
|
|
Symbol = table.Column<string>(type: "text", nullable: false),
|
|
DecimalPlaces = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CurrencyTypes", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Accounts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
OwnerId = table.Column<int>(type: "integer", nullable: false),
|
|
LastActivity = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Balance = table.Column<decimal>(type: "numeric", nullable: false),
|
|
CreatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
InitialBalance = table.Column<decimal>(type: "numeric", nullable: false),
|
|
CurrencyId = table.Column<int>(type: "integer", nullable: false),
|
|
ExternalAccountNumber = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Accounts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Accounts_CurrencyTypes_CurrencyId",
|
|
column: x => x.CurrencyId,
|
|
principalTable: "CurrencyTypes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Accounts_Users_OwnerId",
|
|
column: x => x.OwnerId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Allocs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
Period = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
AccountId = table.Column<int>(type: "integer", nullable: false),
|
|
PersistanceEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
CurrentBalance = table.Column<decimal>(type: "numeric", nullable: false),
|
|
LastTriggeredOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
LastBalanceAdded = table.Column<decimal>(type: "numeric", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Allocs", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Allocs_Accounts_AccountId",
|
|
column: x => x.AccountId,
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Operations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Order = table.Column<int>(type: "integer", nullable: false),
|
|
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
Negative = table.Column<bool>(type: "boolean", nullable: false),
|
|
Mode = table.Column<int>(type: "integer", nullable: false),
|
|
HistoricPeriod = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
HistoricLookbackDepth = table.Column<int>(type: "integer", nullable: false),
|
|
HistoricStatistic = table.Column<int>(type: "integer", nullable: false),
|
|
AbsoluteValue = table.Column<decimal>(type: "numeric", nullable: false),
|
|
Percentage = table.Column<decimal>(type: "numeric", nullable: false),
|
|
AllocId = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Operations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Operations_Allocs_AllocId",
|
|
column: x => x.AllocId,
|
|
principalTable: "Allocs",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Accounts_CurrencyId",
|
|
table: "Accounts",
|
|
column: "CurrencyId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Accounts_OwnerId",
|
|
table: "Accounts",
|
|
column: "OwnerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Allocs_AccountId",
|
|
table: "Allocs",
|
|
column: "AccountId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Operations_AllocId",
|
|
table: "Operations",
|
|
column: "AllocId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Operations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Allocs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Accounts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CurrencyTypes");
|
|
}
|
|
}
|
|
}
|