Skip to content

Commit

Permalink
Add new initial migration
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Oct 29, 2024
1 parent 9898417 commit 52e24dc
Show file tree
Hide file tree
Showing 2 changed files with 385 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RobinTTY.PersonalFinanceDashboard.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BankingInstitutions",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Bic = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
LogoUri = table.Column<string>(type: "TEXT", nullable: false),
Countries = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BankingInstitutions", x => x.Id);
});

migrationBuilder.CreateTable(
name: "ThirdPartyDataRetrievalMetadata",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
DataType = table.Column<int>(type: "INTEGER", nullable: false),
DataSource = table.Column<int>(type: "INTEGER", nullable: false),
LastRetrievalTime = table.Column<DateTime>(type: "TEXT", nullable: false),
RetrievalInterval = table.Column<TimeSpan>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ThirdPartyDataRetrievalMetadata", x => x.Id);
});

migrationBuilder.CreateTable(
name: "BankAccounts",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Iban = table.Column<string>(type: "TEXT", nullable: true),
Bic = table.Column<string>(type: "TEXT", nullable: true),
Bban = table.Column<string>(type: "TEXT", nullable: true),
OwnerName = table.Column<string>(type: "TEXT", nullable: true),
AccountType = table.Column<string>(type: "TEXT", nullable: true),
AssociatedInstitutionId = table.Column<string>(type: "TEXT", nullable: true),
Name = table.Column<string>(type: "TEXT", nullable: true),
Description = table.Column<string>(type: "TEXT", nullable: true),
Balance = table.Column<decimal>(type: "TEXT", nullable: true),
Currency = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BankAccounts", x => x.Id);
table.ForeignKey(
name: "FK_BankAccounts_BankingInstitutions_AssociatedInstitutionId",
column: x => x.AssociatedInstitutionId,
principalTable: "BankingInstitutions",
principalColumn: "Id");
});

migrationBuilder.CreateTable(
name: "Transactions",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
AccountId = table.Column<string>(type: "TEXT", nullable: false),
ValueDate = table.Column<DateTime>(type: "TEXT", nullable: true),
Payer = table.Column<string>(type: "TEXT", nullable: true),
Payee = table.Column<string>(type: "TEXT", nullable: true),
Amount = table.Column<decimal>(type: "TEXT", nullable: false),
Currency = table.Column<string>(type: "TEXT", nullable: false),
Category = table.Column<string>(type: "TEXT", nullable: false),
Notes = table.Column<string>(type: "TEXT", nullable: false),
BankAccountId = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Transactions", x => x.Id);
table.ForeignKey(
name: "FK_Transactions_BankAccounts_BankAccountId",
column: x => x.BankAccountId,
principalTable: "BankAccounts",
principalColumn: "Id");
});

migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Color = table.Column<string>(type: "TEXT", nullable: false),
TransactionId = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tags", x => x.Id);
table.ForeignKey(
name: "FK_Tags_Transactions_TransactionId",
column: x => x.TransactionId,
principalTable: "Transactions",
principalColumn: "Id");
});

migrationBuilder.InsertData(
table: "ThirdPartyDataRetrievalMetadata",
columns: new[] { "Id", "DataSource", "DataType", "LastRetrievalTime", "RetrievalInterval" },
values: new object[] { new Guid("f948e52f-ad17-44b8-9cdf-e0b952f139b3"), 1, 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(7, 0, 0, 0, 0) });

migrationBuilder.CreateIndex(
name: "IX_BankAccounts_AssociatedInstitutionId",
table: "BankAccounts",
column: "AssociatedInstitutionId");

migrationBuilder.CreateIndex(
name: "IX_Tags_TransactionId",
table: "Tags",
column: "TransactionId");

migrationBuilder.CreateIndex(
name: "IX_Transactions_BankAccountId",
table: "Transactions",
column: "BankAccountId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Tags");

migrationBuilder.DropTable(
name: "ThirdPartyDataRetrievalMetadata");

migrationBuilder.DropTable(
name: "Transactions");

migrationBuilder.DropTable(
name: "BankAccounts");

migrationBuilder.DropTable(
name: "BankingInstitutions");
}
}
}

0 comments on commit 52e24dc

Please sign in to comment.