diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index c3d995a..660dd14 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -9,5 +9,6 @@
all
+
\ No newline at end of file
diff --git a/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs b/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs
deleted file mode 100644
index 207a6db..0000000
--- a/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using System;
-using FiscalOS.API.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace FiscalOS.API.Migrations
-{
- [DbContext(typeof(AppDbContext))]
- [Migration("20260201115839_AddUsersAndRefreshTokens")]
- partial class AddUsersAndRefreshTokens
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "10.0.2");
-
- modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("RefreshTokens");
- });
-
- modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Users");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.cs b/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.cs
deleted file mode 100644
index 54fc763..0000000
--- a/src/FiscalOS.API/Migrations/20260201115839_AddUsersAndRefreshTokens.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace FiscalOS.API.Migrations
-{
- ///
- public partial class AddUsersAndRefreshTokens : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "RefreshTokens",
- columns: table => new
- {
- Id = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_RefreshTokens", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Users",
- columns: table => new
- {
- Id = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Users", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "RefreshTokens");
-
- migrationBuilder.DropTable(
- name: "Users");
- }
- }
-}
\ No newline at end of file
diff --git a/src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.cs b/src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.cs
deleted file mode 100644
index 612c7f5..0000000
--- a/src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace FiscalOS.API.Migrations
-{
- ///
- public partial class AddUsernameToUsers : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
- name: "Username",
- table: "Users",
- type: "TEXT",
- nullable: false,
- defaultValue: "");
-
- migrationBuilder.AddColumn(
- name: "UserId",
- table: "RefreshTokens",
- type: "TEXT",
- nullable: false,
- defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
-
- migrationBuilder.CreateIndex(
- name: "IX_RefreshTokens_UserId",
- table: "RefreshTokens",
- column: "UserId");
-
- migrationBuilder.AddForeignKey(
- name: "FK_RefreshTokens_Users_UserId",
- table: "RefreshTokens",
- column: "UserId",
- principalTable: "Users",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_RefreshTokens_Users_UserId",
- table: "RefreshTokens");
-
- migrationBuilder.DropIndex(
- name: "IX_RefreshTokens_UserId",
- table: "RefreshTokens");
-
- migrationBuilder.DropColumn(
- name: "Username",
- table: "Users");
-
- migrationBuilder.DropColumn(
- name: "UserId",
- table: "RefreshTokens");
- }
- }
-}
diff --git a/src/FiscalOS.API/Data/AppDbContext.cs b/src/FiscalOS.Infra/Data/AppDbContext.cs
similarity index 61%
rename from src/FiscalOS.API/Data/AppDbContext.cs
rename to src/FiscalOS.Infra/Data/AppDbContext.cs
index aaaa724..acc250d 100644
--- a/src/FiscalOS.API/Data/AppDbContext.cs
+++ b/src/FiscalOS.Infra/Data/AppDbContext.cs
@@ -1,6 +1,8 @@
-namespace FiscalOS.API.Data;
+using FiscalOS.Core.Data;
-internal sealed class AppDbContext(IOptions ctxOptions) : DbContext
+namespace FiscalOS.Infra.Data;
+
+public sealed class AppDbContext(IOptions ctxOptions) : DbContext
{
private const string DataSourceKey = "Data Source=";
private readonly AppDbContextOptions _ctxOptions = ctxOptions.Value;
@@ -20,13 +22,29 @@ internal sealed class AppDbContext(IOptions ctxOptions) : D
var connectionString = $"{DataSourceKey}{dbPath}";
- optionsBuilder.UseSqlite(connectionString);
+ optionsBuilder.UseSqlite(connectionString)
+ .AddInterceptors(new TimestampInterceptor());
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
+ var entityTypes = modelBuilder.Model.GetEntityTypes()
+ .Where(static e => typeof(Entity).IsAssignableFrom(e.ClrType));
+
+ foreach (var entityType in entityTypes)
+ {
+ modelBuilder.Entity(entityType.ClrType)
+ .HasKey(nameof(Entity.Id));
+
+ modelBuilder.Entity(entityType.ClrType)
+ .Property(nameof(Entity.CreatedAt));
+
+ modelBuilder.Entity(entityType.ClrType)
+ .Property(nameof(Entity.UpdatedAt));
+ }
+
modelBuilder.Entity(static eb =>
{
eb.HasMany(static u => u.RefreshTokens)
@@ -34,8 +52,8 @@ internal sealed class AppDbContext(IOptions ctxOptions) : D
.HasForeignKey(static t => t.UserId)
.OnDelete(DeleteBehavior.Cascade);
- eb.Property(static u => u.Id).ValueGeneratedOnAdd();
eb.Property(static u => u.Username);
+ eb.Property(static u => u.HashedPassword);
});
modelBuilder.Entity(static eb =>
diff --git a/src/FiscalOS.API/Data/AppDbContextOptions.cs b/src/FiscalOS.Infra/Data/AppDbContextOptions.cs
similarity index 77%
rename from src/FiscalOS.API/Data/AppDbContextOptions.cs
rename to src/FiscalOS.Infra/Data/AppDbContextOptions.cs
index 786acc5..b0d48e4 100644
--- a/src/FiscalOS.API/Data/AppDbContextOptions.cs
+++ b/src/FiscalOS.Infra/Data/AppDbContextOptions.cs
@@ -1,6 +1,6 @@
-namespace FiscalOS.API.Data;
+namespace FiscalOS.Infra.Data;
-internal sealed record AppDbContextOptions
+public sealed record AppDbContextOptions
{
public string DatabaseFilePath { get; init; } = string.Empty;
public string GetFullyQualifiedDatabasePath()
@@ -9,7 +9,7 @@ internal sealed record AppDbContextOptions
}
}
-internal sealed record AppDbContextOptionsSetup : IConfigureOptions
+public sealed record AppDbContextOptionsSetup : IConfigureOptions
{
private const string SectionName = nameof(AppDbContextOptions);
private readonly IConfiguration _configuration;
diff --git a/src/FiscalOS.API/Data/MigrationService.cs b/src/FiscalOS.Infra/Data/MigrationService.cs
similarity index 84%
rename from src/FiscalOS.API/Data/MigrationService.cs
rename to src/FiscalOS.Infra/Data/MigrationService.cs
index d236525..596b33a 100644
--- a/src/FiscalOS.API/Data/MigrationService.cs
+++ b/src/FiscalOS.Infra/Data/MigrationService.cs
@@ -1,4 +1,4 @@
-namespace FiscalOS.API.Data;
+namespace FiscalOS.Infra.Data;
internal sealed class MigrationService(
IServiceProvider serviceProvider,
@@ -13,7 +13,7 @@ internal sealed class MigrationService(
using var scope = _serviceProvider.CreateScope();
var context = scope.ServiceProvider.GetRequiredService();
- await context.Database.MigrateAsync(cancellationToken);
+ await context.Database.MigrateAsync(cancellationToken).ConfigureAwait(false);
logger.LogInformation("Database migrations applied.");
}
diff --git a/src/FiscalOS.API/Identity/PasswordHasher.cs b/src/FiscalOS.Infra/Identity/PasswordHasher.cs
similarity index 83%
rename from src/FiscalOS.API/Identity/PasswordHasher.cs
rename to src/FiscalOS.Infra/Identity/PasswordHasher.cs
index 31ee6aa..8ebd890 100644
--- a/src/FiscalOS.API/Identity/PasswordHasher.cs
+++ b/src/FiscalOS.Infra/Identity/PasswordHasher.cs
@@ -1,14 +1,6 @@
-using System.Security.Cryptography;
+namespace FiscalOS.Infra.Identity;
-namespace FiscalOS.API.Identity;
-
-internal interface IPasswordHasher
-{
- string Hash(string password);
- bool Verify(string providedPassword, string hashedPassword);
-}
-
-internal class PasswordHasher : IPasswordHasher
+public sealed class PasswordHasher : IPasswordHasher
{
private const int SaltSize = 16;
private const int HashSize = 32;
diff --git a/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs b/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs
new file mode 100644
index 0000000..e0c3eb4
--- /dev/null
+++ b/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.Designer.cs
@@ -0,0 +1,47 @@
+//
+using System;
+using FiscalOS.Infra.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace FiscalOS.Infra.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20260201115839_AddUsersAndRefreshTokens")]
+ partial class AddUsersAndRefreshTokens
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.2");
+
+ modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("RefreshTokens");
+ });
+
+ modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.cs b/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.cs
new file mode 100644
index 0000000..09951ad
--- /dev/null
+++ b/src/FiscalOS.Infra/Migrations/20260201115839_AddUsersAndRefreshTokens.cs
@@ -0,0 +1,48 @@
+using System;
+
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace FiscalOS.Infra.Migrations
+{
+ ///
+ public partial class AddUsersAndRefreshTokens : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "RefreshTokens",
+ columns: table => new
+ {
+ Id = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RefreshTokens", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ Id = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.Id);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "RefreshTokens");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.Designer.cs b/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.Designer.cs
new file mode 100644
index 0000000..b83358a
--- /dev/null
+++ b/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.Designer.cs
@@ -0,0 +1,72 @@
+//
+using System;
+using FiscalOS.Infra.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace FiscalOS.Infra.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20260201125529_AddUsernameToUsers")]
+ partial class AddUsernameToUsers
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.2");
+
+ modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("RefreshTokens");
+ });
+
+ modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("Username")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ {
+ b.HasOne("FiscalOS.API.Identity.User", "User")
+ .WithMany("RefreshTokens")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ {
+ b.Navigation("RefreshTokens");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.cs b/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.cs
new file mode 100644
index 0000000..77be84c
--- /dev/null
+++ b/src/FiscalOS.Infra/Migrations/20260201125529_AddUsernameToUsers.cs
@@ -0,0 +1,63 @@
+using System;
+
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace FiscalOS.Infra.Migrations
+{
+ ///
+ public partial class AddUsernameToUsers : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Username",
+ table: "Users",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: "");
+
+ migrationBuilder.AddColumn(
+ name: "UserId",
+ table: "RefreshTokens",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RefreshTokens_UserId",
+ table: "RefreshTokens",
+ column: "UserId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_RefreshTokens_Users_UserId",
+ table: "RefreshTokens",
+ column: "UserId",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_RefreshTokens_Users_UserId",
+ table: "RefreshTokens");
+
+ migrationBuilder.DropIndex(
+ name: "IX_RefreshTokens_UserId",
+ table: "RefreshTokens");
+
+ migrationBuilder.DropColumn(
+ name: "Username",
+ table: "Users");
+
+ migrationBuilder.DropColumn(
+ name: "UserId",
+ table: "RefreshTokens");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.Designer.cs b/src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.Designer.cs
similarity index 61%
rename from src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.Designer.cs
rename to src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.Designer.cs
index f0afd9e..3585c32 100644
--- a/src/FiscalOS.API/Migrations/20260201125529_AddUsernameToUsers.Designer.cs
+++ b/src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.Designer.cs
@@ -1,6 +1,6 @@
//
using System;
-using FiscalOS.API.Data;
+using FiscalOS.Infra.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
-namespace FiscalOS.API.Migrations
+namespace FiscalOS.Infra.Migrations
{
[DbContext(typeof(AppDbContext))]
- [Migration("20260201125529_AddUsernameToUsers")]
- partial class AddUsernameToUsers
+ [Migration("20260202010259_AddTimestamps")]
+ partial class AddTimestamps
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -20,12 +20,18 @@ namespace FiscalOS.API.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.2");
- modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.RefreshToken", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
b.Property("UserId")
.HasColumnType("TEXT");
@@ -36,12 +42,22 @@ namespace FiscalOS.API.Migrations
b.ToTable("RefreshTokens");
});
- modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("HashedPassword")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
b.Property("Username")
.IsRequired()
.HasColumnType("TEXT");
@@ -51,9 +67,9 @@ namespace FiscalOS.API.Migrations
b.ToTable("Users");
});
- modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.RefreshToken", b =>
{
- b.HasOne("FiscalOS.API.Identity.User", "User")
+ b.HasOne("FiscalOS.Core.Identity.User", "User")
.WithMany("RefreshTokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -62,7 +78,7 @@ namespace FiscalOS.API.Migrations
b.Navigation("User");
});
- modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.User", b =>
{
b.Navigation("RefreshTokens");
});
diff --git a/src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.cs b/src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.cs
new file mode 100644
index 0000000..c5376b2
--- /dev/null
+++ b/src/FiscalOS.Infra/Migrations/20260202010259_AddTimestamps.cs
@@ -0,0 +1,75 @@
+using System;
+
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace FiscalOS.Infra.Migrations
+{
+ ///
+ public partial class AddTimestamps : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "CreatedAt",
+ table: "Users",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+
+ migrationBuilder.AddColumn(
+ name: "HashedPassword",
+ table: "Users",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: "");
+
+ migrationBuilder.AddColumn(
+ name: "UpdatedAt",
+ table: "Users",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+
+ migrationBuilder.AddColumn(
+ name: "CreatedAt",
+ table: "RefreshTokens",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+
+ migrationBuilder.AddColumn(
+ name: "UpdatedAt",
+ table: "RefreshTokens",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "CreatedAt",
+ table: "Users");
+
+ migrationBuilder.DropColumn(
+ name: "HashedPassword",
+ table: "Users");
+
+ migrationBuilder.DropColumn(
+ name: "UpdatedAt",
+ table: "Users");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedAt",
+ table: "RefreshTokens");
+
+ migrationBuilder.DropColumn(
+ name: "UpdatedAt",
+ table: "RefreshTokens");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FiscalOS.API/Migrations/AppDbContextModelSnapshot.cs b/src/FiscalOS.Infra/Migrations/AppDbContextModelSnapshot.cs
similarity index 63%
rename from src/FiscalOS.API/Migrations/AppDbContextModelSnapshot.cs
rename to src/FiscalOS.Infra/Migrations/AppDbContextModelSnapshot.cs
index 8e86d70..1595455 100644
--- a/src/FiscalOS.API/Migrations/AppDbContextModelSnapshot.cs
+++ b/src/FiscalOS.Infra/Migrations/AppDbContextModelSnapshot.cs
@@ -1,13 +1,13 @@
//
using System;
-using FiscalOS.API.Data;
+using FiscalOS.Infra.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
-namespace FiscalOS.API.Migrations
+namespace FiscalOS.Infra.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
@@ -17,12 +17,18 @@ namespace FiscalOS.API.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.2");
- modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.RefreshToken", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
b.Property("UserId")
.HasColumnType("TEXT");
@@ -33,12 +39,22 @@ namespace FiscalOS.API.Migrations
b.ToTable("RefreshTokens");
});
- modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("HashedPassword")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
b.Property("Username")
.IsRequired()
.HasColumnType("TEXT");
@@ -48,9 +64,9 @@ namespace FiscalOS.API.Migrations
b.ToTable("Users");
});
- modelBuilder.Entity("FiscalOS.API.Identity.RefreshToken", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.RefreshToken", b =>
{
- b.HasOne("FiscalOS.API.Identity.User", "User")
+ b.HasOne("FiscalOS.Core.Identity.User", "User")
.WithMany("RefreshTokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -59,7 +75,7 @@ namespace FiscalOS.API.Migrations
b.Navigation("User");
});
- modelBuilder.Entity("FiscalOS.API.Identity.User", b =>
+ modelBuilder.Entity("FiscalOS.Core.Identity.User", b =>
{
b.Navigation("RefreshTokens");
});
diff --git a/src/FiscalOS.Infra/Usings.cs b/src/FiscalOS.Infra/Usings.cs
new file mode 100644
index 0000000..3910b7f
--- /dev/null
+++ b/src/FiscalOS.Infra/Usings.cs
@@ -0,0 +1,13 @@
+global using System.Security.Cryptography;
+
+global using FiscalOS.Core.Identity;
+global using FiscalOS.Infra.Data;
+global using FiscalOS.Infra.Identity;
+
+global using Microsoft.EntityFrameworkCore;
+global using Microsoft.EntityFrameworkCore.Diagnostics;
+global using Microsoft.Extensions.Configuration;
+global using Microsoft.Extensions.DependencyInjection;
+global using Microsoft.Extensions.Hosting;
+global using Microsoft.Extensions.Logging;
+global using Microsoft.Extensions.Options;
\ No newline at end of file