From 52e24dc5e8f051e82453908956104054ac8e1a5a Mon Sep 17 00:00:00 2001 From: RobinTTY Date: Tue, 29 Oct 2024 01:09:24 +0100 Subject: [PATCH] Add new initial migration --- .../20241028235752_Initial.Designer.cs | 230 ++++++++++++++++++ .../Migrations/20241028235752_Initial.cs | 155 ++++++++++++ 2 files changed, 385 insertions(+) create mode 100644 src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.Designer.cs create mode 100644 src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.cs diff --git a/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.Designer.cs b/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.Designer.cs new file mode 100644 index 0000000..52badcf --- /dev/null +++ b/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.Designer.cs @@ -0,0 +1,230 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RobinTTY.PersonalFinanceDashboard.Infrastructure; + +#nullable disable + +namespace RobinTTY.PersonalFinanceDashboard.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241028235752_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.8"); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.BankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AccountType") + .HasColumnType("TEXT"); + + b.Property("AssociatedInstitutionId") + .HasColumnType("TEXT"); + + b.Property("Balance") + .HasColumnType("TEXT"); + + b.Property("Bban") + .HasColumnType("TEXT"); + + b.Property("Bic") + .HasColumnType("TEXT"); + + b.Property("Currency") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Iban") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("OwnerName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AssociatedInstitutionId"); + + b.ToTable("BankAccounts"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.BankingInstitution", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Bic") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Countries") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LogoUri") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("BankingInstitutions"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.Tag", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Color") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TransactionId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.Transaction", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccountId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("BankAccountId") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Notes") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Payee") + .HasColumnType("TEXT"); + + b.Property("Payer") + .HasColumnType("TEXT"); + + b.Property("ValueDate") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("BankAccountId"); + + b.ToTable("Transactions"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Infrastructure.Entities.ThirdPartyDataRetrievalMetadata", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("DataSource") + .HasColumnType("INTEGER"); + + b.Property("DataType") + .HasColumnType("INTEGER"); + + b.Property("LastRetrievalTime") + .HasColumnType("TEXT"); + + b.Property("RetrievalInterval") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ThirdPartyDataRetrievalMetadata"); + + b.HasData( + new + { + Id = new Guid("f948e52f-ad17-44b8-9cdf-e0b952f139b3"), + DataSource = 1, + DataType = 1, + LastRetrievalTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + RetrievalInterval = new TimeSpan(7, 0, 0, 0, 0) + }); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.BankAccount", b => + { + b.HasOne("RobinTTY.PersonalFinanceDashboard.Core.Models.BankingInstitution", "AssociatedInstitution") + .WithMany() + .HasForeignKey("AssociatedInstitutionId"); + + b.Navigation("AssociatedInstitution"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.Tag", b => + { + b.HasOne("RobinTTY.PersonalFinanceDashboard.Core.Models.Transaction", null) + .WithMany("Tags") + .HasForeignKey("TransactionId"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.Transaction", b => + { + b.HasOne("RobinTTY.PersonalFinanceDashboard.Core.Models.BankAccount", null) + .WithMany("Transactions") + .HasForeignKey("BankAccountId"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.BankAccount", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("RobinTTY.PersonalFinanceDashboard.Core.Models.Transaction", b => + { + b.Navigation("Tags"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.cs b/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.cs new file mode 100644 index 0000000..7912051 --- /dev/null +++ b/src/server/RobinTTY.PersonalFinanceDashboard.Infrastructure/Migrations/20241028235752_Initial.cs @@ -0,0 +1,155 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RobinTTY.PersonalFinanceDashboard.Infrastructure.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "BankingInstitutions", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Bic = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + LogoUri = table.Column(type: "TEXT", nullable: false), + Countries = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BankingInstitutions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ThirdPartyDataRetrievalMetadata", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + DataType = table.Column(type: "INTEGER", nullable: false), + DataSource = table.Column(type: "INTEGER", nullable: false), + LastRetrievalTime = table.Column(type: "TEXT", nullable: false), + RetrievalInterval = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ThirdPartyDataRetrievalMetadata", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BankAccounts", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Iban = table.Column(type: "TEXT", nullable: true), + Bic = table.Column(type: "TEXT", nullable: true), + Bban = table.Column(type: "TEXT", nullable: true), + OwnerName = table.Column(type: "TEXT", nullable: true), + AccountType = table.Column(type: "TEXT", nullable: true), + AssociatedInstitutionId = table.Column(type: "TEXT", nullable: true), + Name = table.Column(type: "TEXT", nullable: true), + Description = table.Column(type: "TEXT", nullable: true), + Balance = table.Column(type: "TEXT", nullable: true), + Currency = table.Column(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(type: "TEXT", nullable: false), + AccountId = table.Column(type: "TEXT", nullable: false), + ValueDate = table.Column(type: "TEXT", nullable: true), + Payer = table.Column(type: "TEXT", nullable: true), + Payee = table.Column(type: "TEXT", nullable: true), + Amount = table.Column(type: "TEXT", nullable: false), + Currency = table.Column(type: "TEXT", nullable: false), + Category = table.Column(type: "TEXT", nullable: false), + Notes = table.Column(type: "TEXT", nullable: false), + BankAccountId = table.Column(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(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + Color = table.Column(type: "TEXT", nullable: false), + TransactionId = table.Column(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"); + } + + /// + 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"); + } + } +}