diff --git a/src/Host/Basira.Host.csproj b/src/Host/Basira.Host.csproj
index a640d66..b81d045 100644
--- a/src/Host/Basira.Host.csproj
+++ b/src/Host/Basira.Host.csproj
@@ -9,6 +9,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Modules/Identity/Infrastructure/Configurations/OrganizationConfiguration.cs b/src/Modules/Identity/Infrastructure/Configurations/OrganizationConfiguration.cs
new file mode 100644
index 0000000..94e1abd
--- /dev/null
+++ b/src/Modules/Identity/Infrastructure/Configurations/OrganizationConfiguration.cs
@@ -0,0 +1,21 @@
+using Basira.Modules.Identity.Domain.Organizations;
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+internal sealed class OrganizationConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("organizations");
+
+ builder.HasKey(o => o.Id);
+ builder.Property(o => o.Id).ValueGeneratedNever();
+
+ builder.Property(o => o.Name)
+ .IsRequired()
+ .HasMaxLength(Organization.NameMaxLength);
+
+ builder.Property(o => o.CreatedAtUtc).IsRequired();
+ }
+}
\ No newline at end of file
diff --git a/src/Modules/Identity/Infrastructure/Configurations/UserConfiguration.cs b/src/Modules/Identity/Infrastructure/Configurations/UserConfiguration.cs
new file mode 100644
index 0000000..df0e382
--- /dev/null
+++ b/src/Modules/Identity/Infrastructure/Configurations/UserConfiguration.cs
@@ -0,0 +1,39 @@
+
+
+using Basira.Modules.Identity.Domain.Organizations;
+using Basira.Modules.Identity.Domain.Users;
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Basira.Modules.Identity.Infrastructure.Configurations;
+
+internal sealed class UserConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("users");
+
+ builder.HasKey(u => u.Id);
+
+ builder.Property(u => u.Id).ValueGeneratedNever();
+
+ builder.Property(u => u.FullName).IsRequired().HasMaxLength(User.FullNameMaxLength);
+
+ builder.Property(u => u.Email).IsRequired().HasMaxLength(User.EmailMaxLength);
+
+ builder.Property(u => u.Role).HasConversion();
+
+ builder.Property(u => u.PasswordHash).IsRequired();
+
+ builder.Property(u => u.CreatedAtUtc).IsRequired();
+
+ builder.Property(u => u.IsActive).IsRequired();
+
+ builder.HasOne()
+ .WithMany()
+ .HasForeignKey(u => u.OrganizationId).OnDelete(DeleteBehavior.Restrict);
+ builder.HasIndex(u => new { u.OrganizationId, u.Email })
+ .IsUnique();
+ }
+}
diff --git a/src/Modules/Identity/Infrastructure/IdentityDbContext.cs b/src/Modules/Identity/Infrastructure/IdentityDbContext.cs
index 1443a36..2132fdb 100644
--- a/src/Modules/Identity/Infrastructure/IdentityDbContext.cs
+++ b/src/Modules/Identity/Infrastructure/IdentityDbContext.cs
@@ -1,11 +1,17 @@
+using Basira.Modules.Identity.Domain.Organizations;
+using Basira.Modules.Identity.Domain.Users;
+
using Microsoft.EntityFrameworkCore;
namespace Basira.Modules.Identity.Infrastructure;
public class IdentityDbContext(DbContextOptions options) : DbContext(options)
{
+ public DbSet Users => Set();
+ public DbSet Organizations => Set();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("identity");
+ modelBuilder.ApplyConfigurationsFromAssembly(typeof(IdentityDbContext).Assembly);
}
}
\ No newline at end of file
diff --git a/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.Designer.cs b/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.Designer.cs
new file mode 100644
index 0000000..b6097a5
--- /dev/null
+++ b/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.Designer.cs
@@ -0,0 +1,97 @@
+//
+using System;
+using Basira.Modules.Identity.Infrastructure;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Basira.Modules.Identity.Infrastructure.Persistence.Migrations
+{
+ [DbContext(typeof(IdentityDbContext))]
+ [Migration("20261203155554_InitialIdentity")]
+ partial class InitialIdentity
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("identity")
+ .HasAnnotation("ProductVersion", "10.0.15")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Organizations.Organization", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.HasKey("Id");
+
+ b.ToTable("organizations", "identity");
+ });
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Users.User", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("IsActive")
+ .HasColumnType("boolean");
+
+ b.Property("OrganizationId")
+ .HasColumnType("uuid");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Role")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OrganizationId", "Email")
+ .IsUnique();
+
+ b.ToTable("users", "identity");
+ });
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Users.User", b =>
+ {
+ b.HasOne("Basira.Modules.Identity.Domain.Organizations.Organization", null)
+ .WithMany()
+ .HasForeignKey("OrganizationId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.cs b/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.cs
new file mode 100644
index 0000000..d00293e
--- /dev/null
+++ b/src/Modules/Identity/Infrastructure/Persistence/Migrations/20261203155554_InitialIdentity.cs
@@ -0,0 +1,77 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Basira.Modules.Identity.Infrastructure.Persistence.Migrations
+{
+ ///
+ public partial class InitialIdentity : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.EnsureSchema(
+ name: "identity");
+
+ migrationBuilder.CreateTable(
+ name: "organizations",
+ schema: "identity",
+ columns: table => new
+ {
+ Id = table.Column(type: "uuid", nullable: false),
+ Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_organizations", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "users",
+ schema: "identity",
+ columns: table => new
+ {
+ Id = table.Column(type: "uuid", nullable: false),
+ OrganizationId = table.Column(type: "uuid", nullable: false),
+ Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: false),
+ FullName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
+ PasswordHash = table.Column(type: "text", nullable: false),
+ Role = table.Column(type: "integer", nullable: false),
+ IsActive = table.Column(type: "boolean", nullable: false),
+ CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_users", x => x.Id);
+ table.ForeignKey(
+ name: "FK_users_organizations_OrganizationId",
+ column: x => x.OrganizationId,
+ principalSchema: "identity",
+ principalTable: "organizations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_users_OrganizationId_Email",
+ schema: "identity",
+ table: "users",
+ columns: new[] { "OrganizationId", "Email" },
+ unique: true);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "users",
+ schema: "identity");
+
+ migrationBuilder.DropTable(
+ name: "organizations",
+ schema: "identity");
+ }
+ }
+}
diff --git a/src/Modules/Identity/Infrastructure/Persistence/Migrations/IdentityDbContextModelSnapshot.cs b/src/Modules/Identity/Infrastructure/Persistence/Migrations/IdentityDbContextModelSnapshot.cs
new file mode 100644
index 0000000..49f79dd
--- /dev/null
+++ b/src/Modules/Identity/Infrastructure/Persistence/Migrations/IdentityDbContextModelSnapshot.cs
@@ -0,0 +1,94 @@
+//
+using System;
+using Basira.Modules.Identity.Infrastructure;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Basira.Modules.Identity.Infrastructure.Persistence.Migrations
+{
+ [DbContext(typeof(IdentityDbContext))]
+ partial class IdentityDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("identity")
+ .HasAnnotation("ProductVersion", "10.0.15")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Organizations.Organization", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.HasKey("Id");
+
+ b.ToTable("organizations", "identity");
+ });
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Users.User", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("IsActive")
+ .HasColumnType("boolean");
+
+ b.Property("OrganizationId")
+ .HasColumnType("uuid");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Role")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OrganizationId", "Email")
+ .IsUnique();
+
+ b.ToTable("users", "identity");
+ });
+
+ modelBuilder.Entity("Basira.Modules.Identity.Domain.Users.User", b =>
+ {
+ b.HasOne("Basira.Modules.Identity.Domain.Organizations.Organization", null)
+ .WithMany()
+ .HasForeignKey("OrganizationId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}