//
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using MinAttest.Infrastructure.Data;
#nullable disable
namespace MinAttest.Infrastructure.Data.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20250913104919_AddAttestVerificationCheck")]
partial class AddAttestVerificationCheck
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("MinAttest.Api.Data.Entities.Attest", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("BlobHash")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property("BlobPath")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property("EmployerId")
.HasColumnType("uniqueidentifier");
b.Property("From")
.HasColumnType("date");
b.Property("IssuedAt")
.HasColumnType("datetimeoffset");
b.Property("IssuedBy")
.HasColumnType("nvarchar(max)");
b.Property("PersonId")
.HasColumnType("uniqueidentifier");
b.Property("Status")
.HasColumnType("int");
b.Property("Summary")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("To")
.HasColumnType("date");
b.HasKey("Id");
b.HasIndex("EmployerId", "Status");
b.HasIndex("PersonId", "Status");
b.ToTable("Attests", t =>
{
t.HasCheckConstraint("CK_Attests_Verification", "(([EmployerId] IS NULL AND [Status] = 2) OR ([EmployerId] IS NOT NULL AND [Status] IN (1,3)))");
});
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.AuditLog", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Action")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("ActorId")
.HasColumnType("uniqueidentifier");
b.Property("ActorType")
.HasColumnType("int");
b.Property("Ip")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property("TargetId")
.HasColumnType("uniqueidentifier");
b.Property("TargetType")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("Timestamp")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("Timestamp");
b.ToTable("AuditLogs");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Employer", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property("OrgNumber")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.HasKey("Id");
b.HasIndex("OrgNumber");
b.ToTable("Employers");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Person", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Email")
.HasColumnType("nvarchar(max)");
b.Property("NationalIdEncrypted")
.HasColumnType("nvarchar(max)");
b.Property("NationalIdHash")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("Phone")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("NationalIdHash");
b.ToTable("Persons");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.ShareLink", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("AttestId")
.HasColumnType("uniqueidentifier");
b.Property("Code")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("ExpiresAt")
.HasColumnType("datetimeoffset");
b.Property("OneTime")
.HasColumnType("bit");
b.Property("RevokedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("AttestId");
b.HasIndex("Code")
.IsUnique();
b.ToTable("ShareLinks");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Attest", b =>
{
b.HasOne("MinAttest.Api.Data.Entities.Employer", "Employer")
.WithMany("Attests")
.HasForeignKey("EmployerId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("MinAttest.Api.Data.Entities.Person", "Person")
.WithMany("Attests")
.HasForeignKey("PersonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employer");
b.Navigation("Person");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.ShareLink", b =>
{
b.HasOne("MinAttest.Api.Data.Entities.Attest", "Attest")
.WithMany("ShareLinks")
.HasForeignKey("AttestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Attest");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Attest", b =>
{
b.Navigation("ShareLinks");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Employer", b =>
{
b.Navigation("Attests");
});
modelBuilder.Entity("MinAttest.Api.Data.Entities.Person", b =>
{
b.Navigation("Attests");
});
#pragma warning restore 612, 618
}
}
}