diff --git a/src/FiscalOS.Infra/DependencyInjection/ServiceCollectionExtensions.cs b/src/FiscalOS.Infra/DependencyInjection/ServiceCollectionExtensions.cs index 631215d..b4374ca 100644 --- a/src/FiscalOS.Infra/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/FiscalOS.Infra/DependencyInjection/ServiceCollectionExtensions.cs @@ -5,7 +5,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddInfrastructure(this IServiceCollection services) { services.AddSingleton(); - + services.AddHttpClient(); services.AddSingleton(TimeProvider.System); services.AddSingleton(); diff --git a/src/FiscalOS.Infra/Migrations/20260212215015_InstitutionAndMetadata.cs b/src/FiscalOS.Infra/Migrations/20260212215015_InstitutionAndMetadata.cs index 14537e8..e67468b 100644 --- a/src/FiscalOS.Infra/Migrations/20260212215015_InstitutionAndMetadata.cs +++ b/src/FiscalOS.Infra/Migrations/20260212215015_InstitutionAndMetadata.cs @@ -1,81 +1,82 @@ using System; + using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FiscalOS.Infra.Migrations { + /// + public partial class InstitutionAndMetadata : Migration + { /// - public partial class InstitutionAndMetadata : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Institution", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - UserId = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false), - UpdatedAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Institution", x => x.Id); - table.ForeignKey( - name: "FK_Institution_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "Institution", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + UserId = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Institution", x => x.Id); + table.ForeignKey( + name: "FK_Institution_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "InstitutionMetadata", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - Type = table.Column(type: "TEXT", maxLength: 21, nullable: false), - InstitutionId = table.Column(type: "TEXT", nullable: false), - PlaidId = table.Column(type: "TEXT", nullable: true), - PlaidName = table.Column(type: "TEXT", nullable: true), - EncryptedAccessToken = table.Column(type: "TEXT", nullable: true), - CreatedAt = table.Column(type: "TEXT", nullable: false), - UpdatedAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_InstitutionMetadata", x => x.Id); - table.ForeignKey( - name: "FK_InstitutionMetadata_Institution_InstitutionId", - column: x => x.InstitutionId, - principalTable: "Institution", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "InstitutionMetadata", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "TEXT", maxLength: 21, nullable: false), + InstitutionId = table.Column(type: "TEXT", nullable: false), + PlaidId = table.Column(type: "TEXT", nullable: true), + PlaidName = table.Column(type: "TEXT", nullable: true), + EncryptedAccessToken = table.Column(type: "TEXT", nullable: true), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InstitutionMetadata", x => x.Id); + table.ForeignKey( + name: "FK_InstitutionMetadata_Institution_InstitutionId", + column: x => x.InstitutionId, + principalTable: "Institution", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_Institution_UserId", - table: "Institution", - column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_Institution_UserId", + table: "Institution", + column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_InstitutionMetadata_InstitutionId", - table: "InstitutionMetadata", - column: "InstitutionId", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "InstitutionMetadata"); - - migrationBuilder.DropTable( - name: "Institution"); - } + migrationBuilder.CreateIndex( + name: "IX_InstitutionMetadata_InstitutionId", + table: "InstitutionMetadata", + column: "InstitutionId", + unique: true); } -} + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "InstitutionMetadata"); + + migrationBuilder.DropTable( + name: "Institution"); + } + } +} \ No newline at end of file diff --git a/src/FiscalOS.Infra/Migrations/20260213130218_AccountAndMetadata.cs b/src/FiscalOS.Infra/Migrations/20260213130218_AccountAndMetadata.cs index 20e0e04..c536214 100644 --- a/src/FiscalOS.Infra/Migrations/20260213130218_AccountAndMetadata.cs +++ b/src/FiscalOS.Infra/Migrations/20260213130218_AccountAndMetadata.cs @@ -1,92 +1,93 @@ using System; + using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FiscalOS.Infra.Migrations { + /// + public partial class AccountAndMetadata : Migration + { /// - public partial class AccountAndMetadata : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Account", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - UserId = table.Column(type: "TEXT", nullable: false), - InstituionId = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false), - UpdatedAt = table.Column(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); - }); + migrationBuilder.CreateTable( + name: "Account", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + UserId = table.Column(type: "TEXT", nullable: false), + InstituionId = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(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); + }); - migrationBuilder.CreateTable( - name: "AccountMetadata", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - Type = table.Column(type: "TEXT", maxLength: 21, nullable: false), - AccountId = table.Column(type: "TEXT", nullable: false), - PlaidId = table.Column(type: "TEXT", nullable: true), - PlaidName = table.Column(type: "TEXT", nullable: true), - CreatedAt = table.Column(type: "TEXT", nullable: false), - UpdatedAt = table.Column(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); - }); + migrationBuilder.CreateTable( + name: "AccountMetadata", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Type = table.Column(type: "TEXT", maxLength: 21, nullable: false), + AccountId = table.Column(type: "TEXT", nullable: false), + PlaidId = table.Column(type: "TEXT", nullable: true), + PlaidName = table.Column(type: "TEXT", nullable: true), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(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); + }); - migrationBuilder.CreateIndex( - name: "IX_Account_InstituionId", - table: "Account", - column: "InstituionId"); + migrationBuilder.CreateIndex( + name: "IX_Account_InstituionId", + table: "Account", + column: "InstituionId"); - migrationBuilder.CreateIndex( - name: "IX_Account_UserId", - table: "Account", - column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_Account_UserId", + table: "Account", + column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_AccountMetadata_AccountId", - table: "AccountMetadata", - column: "AccountId", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AccountMetadata"); - - migrationBuilder.DropTable( - name: "Account"); - } + migrationBuilder.CreateIndex( + name: "IX_AccountMetadata_AccountId", + table: "AccountMetadata", + column: "AccountId", + unique: true); } -} + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AccountMetadata"); + + migrationBuilder.DropTable( + name: "Account"); + } + } +} \ No newline at end of file diff --git a/src/FiscalOS.Infra/Migrations/20260213180002_FixAccountInstitutionColumnName.cs b/src/FiscalOS.Infra/Migrations/20260213180002_FixAccountInstitutionColumnName.cs index d57a9aa..798f65a 100644 --- a/src/FiscalOS.Infra/Migrations/20260213180002_FixAccountInstitutionColumnName.cs +++ b/src/FiscalOS.Infra/Migrations/20260213180002_FixAccountInstitutionColumnName.cs @@ -4,59 +4,59 @@ namespace FiscalOS.Infra.Migrations { + /// + public partial class FixAccountInstitutionColumnName : Migration + { /// - public partial class FixAccountInstitutionColumnName : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Account_Institution_InstituionId", - table: "Account"); + migrationBuilder.DropForeignKey( + name: "FK_Account_Institution_InstituionId", + table: "Account"); - migrationBuilder.RenameColumn( - name: "InstituionId", - table: "Account", - newName: "InstitutionId"); + migrationBuilder.RenameColumn( + name: "InstituionId", + table: "Account", + newName: "InstitutionId"); - migrationBuilder.RenameIndex( - name: "IX_Account_InstituionId", - table: "Account", - newName: "IX_Account_InstitutionId"); + migrationBuilder.RenameIndex( + name: "IX_Account_InstituionId", + table: "Account", + newName: "IX_Account_InstitutionId"); - migrationBuilder.AddForeignKey( - name: "FK_Account_Institution_InstitutionId", - table: "Account", - column: "InstitutionId", - principalTable: "Institution", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Account_Institution_InstitutionId", - table: "Account"); - - migrationBuilder.RenameColumn( - name: "InstitutionId", - table: "Account", - newName: "InstituionId"); - - migrationBuilder.RenameIndex( - name: "IX_Account_InstitutionId", - table: "Account", - newName: "IX_Account_InstituionId"); - - migrationBuilder.AddForeignKey( - name: "FK_Account_Institution_InstituionId", - table: "Account", - column: "InstituionId", - principalTable: "Institution", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } + migrationBuilder.AddForeignKey( + name: "FK_Account_Institution_InstitutionId", + table: "Account", + column: "InstitutionId", + principalTable: "Institution", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); } -} + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Account_Institution_InstitutionId", + table: "Account"); + + migrationBuilder.RenameColumn( + name: "InstitutionId", + table: "Account", + newName: "InstituionId"); + + migrationBuilder.RenameIndex( + name: "IX_Account_InstitutionId", + table: "Account", + newName: "IX_Account_InstituionId"); + + migrationBuilder.AddForeignKey( + name: "FK_Account_Institution_InstituionId", + table: "Account", + column: "InstituionId", + principalTable: "Institution", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} \ No newline at end of file diff --git a/src/FiscalOS.Infra/Migrations/20260214112234_AddBalancesWithConnectionToAccounts.cs b/src/FiscalOS.Infra/Migrations/20260214112234_AddBalancesWithConnectionToAccounts.cs index 997b64a..82ed630 100644 --- a/src/FiscalOS.Infra/Migrations/20260214112234_AddBalancesWithConnectionToAccounts.cs +++ b/src/FiscalOS.Infra/Migrations/20260214112234_AddBalancesWithConnectionToAccounts.cs @@ -1,49 +1,50 @@ using System; + using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FiscalOS.Infra.Migrations { + /// + public partial class AddBalancesWithConnectionToAccounts : Migration + { /// - public partial class AddBalancesWithConnectionToAccounts : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Balance", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - AccountId = table.Column(type: "TEXT", nullable: false), - Current = table.Column(type: "TEXT", nullable: false), - Available = table.Column(type: "TEXT", nullable: false), - CreatedAt = table.Column(type: "TEXT", nullable: false), - UpdatedAt = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Balance", x => x.Id); - table.ForeignKey( - name: "FK_Balance_Account_AccountId", - column: x => x.AccountId, - principalTable: "Account", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "Balance", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + AccountId = table.Column(type: "TEXT", nullable: false), + Current = table.Column(type: "TEXT", nullable: false), + Available = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Balance", x => x.Id); + table.ForeignKey( + name: "FK_Balance_Account_AccountId", + column: x => x.AccountId, + principalTable: "Account", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_Balance_AccountId", - table: "Balance", - column: "AccountId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Balance"); - } + migrationBuilder.CreateIndex( + name: "IX_Balance_AccountId", + table: "Balance", + column: "AccountId"); } -} + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Balance"); + } + } +} \ No newline at end of file diff --git a/src/FiscalOS.Infra/Migrations/20260214122622_AddCurrencyCodeToBalanceModel.cs b/src/FiscalOS.Infra/Migrations/20260214122622_AddCurrencyCodeToBalanceModel.cs index 5f40b46..f661960 100644 --- a/src/FiscalOS.Infra/Migrations/20260214122622_AddCurrencyCodeToBalanceModel.cs +++ b/src/FiscalOS.Infra/Migrations/20260214122622_AddCurrencyCodeToBalanceModel.cs @@ -4,26 +4,26 @@ namespace FiscalOS.Infra.Migrations { + /// + public partial class AddCurrencyCodeToBalanceModel : Migration + { /// - public partial class AddCurrencyCodeToBalanceModel : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CurrencyCode", - table: "Balance", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CurrencyCode", - table: "Balance"); - } + migrationBuilder.AddColumn( + name: "CurrencyCode", + table: "Balance", + type: "TEXT", + nullable: false, + defaultValue: ""); } -} + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CurrencyCode", + table: "Balance"); + } + } +} \ No newline at end of file diff --git a/tests/FiscalOS.API.Tests/Infra/SerializableDictionary.cs b/tests/FiscalOS.API.Tests/Infra/SerializableDictionary.cs index 9b36319..0b31225 100644 --- a/tests/FiscalOS.API.Tests/Infra/SerializableDictionary.cs +++ b/tests/FiscalOS.API.Tests/Infra/SerializableDictionary.cs @@ -4,7 +4,7 @@ public interface ISerializableDictionary : IDictionary +public class SerializableDictionary : Dictionary, ISerializableDictionary where TKey : notnull { public SerializableDictionary() { }