Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update email claim properties (#2159)
Leendert de Borst08fa527f25f4
diff --git a/apps/server/Databases/AliasClientDb/SharedFolderEncryptionKey.cs b/apps/server/Databases/AliasClientDb/SharedFolderEncryptionKey.csindex b27420203..31d5c489d 100644--- a/apps/server/Databases/AliasClientDb/SharedFolderEncryptionKey.cs+++ b/apps/server/Databases/AliasClientDb/SharedFolderEncryptionKey.cs@@ -44,7 +44,7 @@ public class SharedFolderEncryptionKey : SyncableEntitypublic Guid SharedFolderId { get; set; }/// <summary>- /// Gets or sets the public key. Published to the server (as a manifest-scoped UserEncryptionKey) so+ /// Gets or sets the public key. Published to the server (as a manifest-scoped EncryptionKey) so/// the SMTP service can encrypt incoming mail for the folder's aliases without decrypting anything./// </summary>[Required]diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.csindex 1c23f20c5..2e0bd4987 100644--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs@@ -366,30 +366,15 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConbuilder.Property(e => e.Metadata).HasColumnType("jsonb");});- // Configure EmailClaim - Group relationship. SetNull: when the owning group is deleted (its- // owner deleted their account) the claim becomes an ownerless tombstone, preserved to prevent- // re-use of the email address; delivery rejects mail for it.+ /*+ * Configure EmailClaim - VaultManifest relationship, the claim's ownership reference.+ */modelBuilder.Entity<EmailClaim>()- .HasOne(e => e.OwnerGroup)+ .HasOne(e => e.VaultManifest).WithMany()- .HasForeignKey(e => e.OwnerGroupId)+ .HasForeignKey(e => e.VaultManifestId).OnDelete(DeleteBehavior.SetNull);- /*- * Configure EmailClaim - VaultManifest relationship. SetNull for the same reason the user FK is:- * the claim outlives the folder so the address cannot be re-registered by someone else. A claim left- * with a null manifest is an orphaned shared alias, which reconciliation then disables.- */- modelBuilder.Entity<EmailClaim>(builder =>- {- builder.HasOne(e => e.VaultManifest)- .WithMany()- .HasForeignKey(e => e.VaultManifestId)- .OnDelete(DeleteBehavior.SetNull);-- builder.HasIndex(e => e.VaultManifestId);- });-// Configure Email - EncryptionKey relationshipmodelBuilder.Entity<Email>().HasOne(l => l.EncryptionKey)diff --git a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs b/apps/server/Databases/AliasServerDb/AliasVaultUser.csindex 18bd327e9..5e16853ac 100644--- a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs+++ b/apps/server/Databases/AliasServerDb/AliasVaultUser.cs@@ -15,12 +15,23 @@ using Microsoft.AspNetCore.Identity;public class AliasVaultUser : IdentityUser{/// <summary>- /// Gets or sets the SRP identity used for authentication. This is a fixed value (typically a random GUID)- /// that is used for all SRP operations, is set during registration, and never changes.+ /// Gets or sets the SRP identity used for authentication. This is a fixed value that is used for all SRP operations,+ /// is set during registration, and never changes./// </summary>[System.ComponentModel.DataAnnotations.StringLength(255)]public string? SrpIdentity { get; set; }+ /// <summary>+ /// Gets or sets the user's personal <see cref="Group"/>: the group that owns their root vault and personal+ /// email claims.+ /// </summary>+ public Guid PersonalGroupId { get; set; }++ /// <summary>+ /// Gets or sets the navigation property to the user's personal group.+ /// </summary>+ public virtual Group PersonalGroup { get; set; } = null!;+/// <summary>/// Gets or sets created timestamp./// </summary>@@ -82,16 +93,6 @@ public class AliasVaultUser : IdentityUser/// </summary>public int EmailsReceived { get; set; } = 0;- /// <summary>- /// Gets or sets the collection of vault manifest revisions owned by this user (across all manifests and kinds).- /// </summary>- public virtual ICollection<VaultManifest> VaultManifests { get; set; } = [];-- /// <summary>- /// Gets or sets the collection of EmailClaims.- /// </summary>- public virtual ICollection<UserEmailClaim> EmailClaims { get; set; } = [];-/// <summary>/// Gets or sets the collection of EncryptionKeys./// </summary>diff --git a/apps/server/Databases/AliasServerDb/EmailClaim.cs b/apps/server/Databases/AliasServerDb/EmailClaim.csindex 24a043693..743fbb0ac 100644--- a/apps/server/Databases/AliasServerDb/EmailClaim.cs+++ b/apps/server/Databases/AliasServerDb/EmailClaim.cs@@ -12,11 +12,12 @@ using System.ComponentModel.DataAnnotations.Schema;using Microsoft.EntityFrameworkCore;/// <summary>-/// EmailClaim object. This object is used to reserve an email address for a user.+/// EmailClaim object. This object is used to reserve an email address. The claim is filed against the manifest+/// the alias lives in (see <see cref="VaultManifestId"/>), which is what its owning group is resolved from./// </summary>[Index(nameof(Address), IsUnique = true)]-[Index(nameof(OwnerGroupId), nameof(Disabled))]-[Index(nameof(OwnerGroupId), nameof(CreatedAt))]+[Index(nameof(VaultManifestId), nameof(Disabled))]+[Index(nameof(VaultManifestId), nameof(CreatedAt))]public class EmailClaim{/// <summary>@@ -26,38 +27,16 @@ public class EmailClaimpublic Guid Id { get; set; }/// <summary>- /// Gets or sets the shared folder this alias lives in, or null for a personal alias.- /// <para>- /// This is what makes a shared alias belong to the <em>folder</em> rather than to whichever member happened- /// to create it. Without it, revoking that member disables an alias sitting in someone else's folder (their- /// next push no longer lists it), and their account deletion strands the address permanently. Read access- /// and routing reconciliation both key off this column.- /// </para>+ /// Gets or sets the manifest this alias lives in (and from which owner group can be derived from)./// </summary>public Guid? VaultManifestId { get; set; }/// <summary>- /// Gets or sets the navigation property to the shared folder this alias lives in.+ /// Gets or sets the navigation property to the manifest this alias lives in./// </summary>[ForeignKey("VaultManifestId")]public virtual VaultManifest? VaultManifest { get; set; }- /// <summary>- /// Gets or sets the group this alias is owned by and billed to — like every manifest, an alias is owned by- /// a group, never by a user. For a personal alias that is the claimer's Personal group; for an alias in a- /// shared folder it is the group that owns the folder, so a family's aliases draw on the family owner's- /// allowance no matter which member created them, and stay correct when the folder is transferred.- /// Null when the owning group has been deleted (the user deleted their account): the claim is then a- /// tombstone kept solely to prevent re-use of the address, and delivery rejects its mail.- /// </summary>- public Guid? OwnerGroupId { get; set; }-- /// <summary>- /// Gets or sets the navigation property to the owning group.- /// </summary>- [ForeignKey("OwnerGroupId")]- public virtual Group? OwnerGroup { get; set; }-/// <summary>/// Gets or sets the encryption key incoming mail for this alias is encrypted with. For most cases this will be null,/// which means the routing owner's primary personal key is used, resolved at delivery time. For aliases that are shareddiff --git a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.csnew file mode 100644index 000000000..b64008739--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.Designer.cs@@ -0,0 +1,1579 @@+// <auto-generated />+using System;+using AliasServerDb;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;++#nullable disable++namespace AliasServerDb.Migrations+{+ [DbContext(typeof(AliasServerDbContext))]+ [Migration("20260730082935_EmailClaimOwnershipViaManifest")]+ partial class EmailClaimOwnershipViaManifest+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.10")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true)+ .HasAnnotation("Relational:MaxIdentifierLength", 63);++ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);++ modelBuilder.Entity("AliasServerDb.AdminRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminRoles");+ });++ modelBuilder.Entity("AliasServerDb.AdminUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastPasswordChanged")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AliasVaultRoles");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<bool>("Blocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("BlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<int>("EmailsReceived")+ .HasColumnType("integer");++ b.Property<DateTime?>("LastActivityDate")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<Guid>("PersonalGroupId")+ .HasColumnType("uuid");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("SrpIdentity")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("PersonalGroupId")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");++ b.ToTable("AliasVaultUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("DeviceIdentifier")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("ExpireDate")+ .HasMaxLength(255)+ .HasColumnType("timestamp with time zone");++ b.Property<string>("IpAddress")+ .HasMaxLength(45)+ .HasColumnType("character varying(45)");++ b.Property<string>("PreviousTokenValue")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AliasVaultUserRefreshTokens");+ });++ modelBuilder.Entity("AliasServerDb.AuthLog", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("AdditionalInfo")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Browser")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Client")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Country")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DeviceType")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<int>("EventType")+ .HasColumnType("integer");++ b.Property<int?>("FailureReason")+ .HasColumnType("integer");++ b.Property<string>("IpAddress")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<bool>("IsSuccess")+ .HasColumnType("boolean");++ b.Property<bool>("IsSuspiciousActivity")+ .HasColumnType("boolean");++ b.Property<string>("OperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("RequestPath")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("Timestamp")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Username")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex(new[] { "EventType" }, "IX_EventType");++ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");++ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");++ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")+ .IsDescending(false, false, true);++ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")+ .IsDescending(false, true);++ b.ToTable("AuthLogs");+ });++ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<bool>("BlockLogin")+ .HasColumnType("boolean");++ b.Property<bool>("BlockRegistration")+ .HasColumnType("boolean");++ b.Property<bool>("BlockShadow")+ .HasColumnType("boolean");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<string>("IpRange")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Reason")+ .HasMaxLength(500)+ .HasColumnType("character varying(500)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");++ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")+ .IsUnique();++ b.ToTable("BlockedIpRanges");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedSymmetricKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<Guid>("EncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");++ b.Property<string>("From")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageHtml")+ .HasColumnType("text");++ b.Property<string>("MessagePlain")+ .HasColumnType("text");++ b.Property<string>("MessagePreview")+ .HasColumnType("text");++ b.Property<string>("MessageSource")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("PushNotificationSent")+ .HasColumnType("boolean");++ b.Property<string>("Subject")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("To")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("EncryptionKeyId");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("Visible");++ b.HasIndex("To", "DateSystem");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<string>("Filename")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("Filesize")+ .HasColumnType("integer");++ b.Property<string>("MimeType")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("EmailId");++ b.ToTable("EmailAttachments");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Disabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("EncryptionKeyId")+ .HasColumnType("uuid");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("EncryptionKeyId");++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "Disabled");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId");++ b.HasIndex("UserId", "VaultManifestId", "IsPrimary");++ b.ToTable("EncryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.ToTable("Groups");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("Role")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.HasIndex("GroupId", "UserId")+ .IsUnique();++ b.ToTable("GroupMembers");+ });++ modelBuilder.Entity("AliasServerDb.Log", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("character varying(128)");++ b.Property<string>("LogEvent")+ .IsRequired()+ .HasColumnType("text")+ .HasColumnName("LogEvent");++ b.Property<string>("Message")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageTemplate")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Properties")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("SourceContext")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("TimeStamp")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<DateTime?>("ClearedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ClientIpAddress")+ .HasColumnType("text");++ b.Property<string>("ClientPublicKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedDecryptionKey")+ .HasColumnType("text");++ b.Property<DateTime?>("FulfilledAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("MobileIpAddress")+ .HasColumnType("text");++ b.Property<DateTime?>("RetrievedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");++ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");++ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");++ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");++ b.HasIndex(new[] { "UserId" }, "IX_UserId");++ b.ToTable("MobileLoginRequests");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int?>("AppliesToAccountAgeMaxDays")+ .HasColumnType("integer");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("EffectiveFrom")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("EffectiveUntil")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<int>("LimitType")+ .HasColumnType("integer");++ b.Property<int>("MaxCount")+ .HasColumnType("integer");++ b.Property<string>("Notes")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<int?>("Tier")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<int>("WindowSeconds")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("Tier");++ b.HasIndex("UserId");++ b.HasIndex("LimitType", "Enabled");++ b.ToTable("RateLimits");+ });++ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>+ {+ b.Property<string>("Key")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("Key");++ b.ToTable("ServerSettings");+ });++ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<TimeOnly?>("EndTime")+ .HasColumnType("time without time zone");++ b.Property<string>("ErrorMessage")+ .HasColumnType("text");++ b.Property<bool>("IsOnDemand")+ .HasColumnType("boolean");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("RunDate")+ .HasColumnType("timestamp with time zone");++ b.Property<TimeOnly>("StartTime")+ .HasColumnType("time without time zone");++ b.Property<int>("Status")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.ToTable("TaskRunnerJobs");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.Property<string>("Hash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("LastReferencedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("SizeBytes")+ .HasColumnType("integer");++ b.HasKey("Hash", "OwnerUserId");++ b.HasIndex("OwnerUserId", "Category");++ b.ToTable("VaultBlobObjects");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category");++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category", "RevisionNumber");++ b.ToTable("VaultDataBucketsHistory");+ });++ modelBuilder.Entity("AliasServerDb.VaultKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<string>("KeyType")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<Guid?>("RecipientPublicKeyId")+ .HasColumnType("uuid");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("WrapScheme")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<string>("WrappedVek")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId")+ .HasDatabaseName("IX_VaultKeys_VaultManifestId");++ b.HasIndex("UserId", "KeyType", "VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");++ b.ToTable("VaultKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("ManifestId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<bool>("IsRoot")+ .HasColumnType("boolean");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Name")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("OwnerGroupId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId");++ b.HasIndex("OwnerGroupId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifests_OwnerGroupId_Root")+ .HasFilter("\"IsRoot\"");++ b.ToTable("VaultManifests");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Salt")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId", "RevisionNumber");++ b.ToTable("VaultManifestsHistory", (string)null);+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DesiredStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("Heartbeat")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ServiceName")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.ToTable("WorkerServiceStatuses");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("FriendlyName")+ .HasColumnType("text");++ b.Property<string>("Xml")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("DataProtectionKeys");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("RoleClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("UserClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>+ {+ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("ProviderKey")+ .HasColumnType("text");++ b.Property<string>("ProviderDisplayName")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("LoginProvider", "ProviderKey");++ b.ToTable("UserLogins", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("UserId", "RoleId");++ b.ToTable("UserRoles", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("UserTokens", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.HasOne("AliasServerDb.Group", "PersonalGroup")+ .WithOne()+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")+ .OnDelete(DeleteBehavior.Restrict)+ .IsRequired();++ b.Navigation("PersonalGroup");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("EncryptionKeyId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("EncryptionKey");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Attachments")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey")+ .WithMany()+ .HasForeignKey("EncryptionKeyId")+ .OnDelete(DeleteBehavior.Restrict);++ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("EncryptionKey");++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EncryptionKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany("Members")+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Group");++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")+ .WithMany()+ .HasForeignKey("OwnerUserId", "Category")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Bucket");+ });++ modelBuilder.Entity("AliasServerDb.VaultKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("OwnerGroup");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("EncryptionKeys");++ b.Navigation("VaultKeys");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>+ {+ b.Navigation("Emails");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.csnew file mode 100644index 000000000..dc9effae3--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260730082935_EmailClaimOwnershipViaManifest.cs@@ -0,0 +1,110 @@+using System;+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class EmailClaimOwnershipViaManifest : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.Sql(@"+ UPDATE ""EmailClaims"" c+ SET ""VaultManifestId"" = m.""ManifestId""+ FROM ""VaultManifests"" m+ WHERE m.""OwnerGroupId"" = c.""OwnerGroupId""+ AND m.""IsRoot""+ AND c.""VaultManifestId"" IS NULL;");++ migrationBuilder.DropForeignKey(+ name: "FK_EmailClaims_Groups_OwnerGroupId",+ table: "EmailClaims");++ migrationBuilder.DropIndex(+ name: "IX_EmailClaims_OwnerGroupId_CreatedAt",+ table: "EmailClaims");++ migrationBuilder.DropIndex(+ name: "IX_EmailClaims_OwnerGroupId_Disabled",+ table: "EmailClaims");++ migrationBuilder.DropIndex(+ name: "IX_EmailClaims_VaultManifestId",+ table: "EmailClaims");++ migrationBuilder.DropColumn(+ name: "OwnerGroupId",+ table: "EmailClaims");++ migrationBuilder.CreateIndex(+ name: "IX_EmailClaims_VaultManifestId_CreatedAt",+ table: "EmailClaims",+ columns: new[] { "VaultManifestId", "CreatedAt" });++ migrationBuilder.CreateIndex(+ name: "IX_EmailClaims_VaultManifestId_Disabled",+ table: "EmailClaims",+ columns: new[] { "VaultManifestId", "Disabled" });+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "IX_EmailClaims_VaultManifestId_CreatedAt",+ table: "EmailClaims");++ migrationBuilder.DropIndex(+ name: "IX_EmailClaims_VaultManifestId_Disabled",+ table: "EmailClaims");++ migrationBuilder.AddColumn<Guid>(+ name: "OwnerGroupId",+ table: "EmailClaims",+ type: "uuid",+ nullable: true);++ // Repopulate the owning group from each claim's manifest, then restore the previous convention in+ // which a personal alias carried no manifest at all — otherwise the reverted code would read every+ // personal claim as if it lived in a shared folder.+ migrationBuilder.Sql(@"+ UPDATE ""EmailClaims"" c+ SET ""OwnerGroupId"" = m.""OwnerGroupId""+ FROM ""VaultManifests"" m+ WHERE m.""ManifestId"" = c.""VaultManifestId"";");++ migrationBuilder.Sql(@"+ UPDATE ""EmailClaims"" c+ SET ""VaultManifestId"" = NULL+ FROM ""VaultManifests"" m+ WHERE m.""ManifestId"" = c.""VaultManifestId""+ AND m.""IsRoot"";");++ migrationBuilder.CreateIndex(+ name: "IX_EmailClaims_OwnerGroupId_CreatedAt",+ table: "EmailClaims",+ columns: new[] { "OwnerGroupId", "CreatedAt" });++ migrationBuilder.CreateIndex(+ name: "IX_EmailClaims_OwnerGroupId_Disabled",+ table: "EmailClaims",+ columns: new[] { "OwnerGroupId", "Disabled" });++ migrationBuilder.CreateIndex(+ name: "IX_EmailClaims_VaultManifestId",+ table: "EmailClaims",+ column: "VaultManifestId");++ migrationBuilder.AddForeignKey(+ name: "FK_EmailClaims_Groups_OwnerGroupId",+ table: "EmailClaims",+ column: "OwnerGroupId",+ principalTable: "Groups",+ principalColumn: "Id",+ onDelete: ReferentialAction.SetNull);+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex 2f49ac160..bce5efe34 100644--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -174,6 +174,9 @@ namespace AliasServerDb.Migrationsb.Property<string>("PasswordHash").HasColumnType("text");+ b.Property<Guid>("PersonalGroupId")+ .HasColumnType("uuid");+b.Property<string>("PhoneNumber").HasColumnType("text");@@ -204,6 +207,10 @@ namespace AliasServerDb.Migrationsb.HasKey("Id");+ b.HasIndex("PersonalGroupId")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");+b.ToTable("AliasVaultUsers");});@@ -393,6 +400,10 @@ namespace AliasServerDb.Migrations.IsRequired().HasColumnType("text");+ b.Property<Guid>("EncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");+b.Property<string>("From").IsRequired().HasColumnType("text");@@ -437,10 +448,6 @@ namespace AliasServerDb.Migrations.IsRequired().HasColumnType("text");- b.Property<Guid>("UserEncryptionKeyId")- .HasMaxLength(255)- .HasColumnType("uuid");-b.Property<bool>("Visible").HasColumnType("boolean");@@ -450,9 +457,9 @@ namespace AliasServerDb.Migrationsb.HasIndex("DateSystem");- b.HasIndex("PushNotificationSent");+ b.HasIndex("EncryptionKeyId");- b.HasIndex("UserEncryptionKeyId");+ b.HasIndex("PushNotificationSent");b.HasIndex("Visible");@@ -497,6 +504,150 @@ namespace AliasServerDb.Migrationsb.ToTable("EmailAttachments");});+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Disabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("EncryptionKeyId")+ .HasColumnType("uuid");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("EncryptionKeyId");++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "Disabled");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId");++ b.HasIndex("UserId", "VaultManifestId", "IsPrimary");++ b.ToTable("EncryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.ToTable("Groups");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("Role")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.HasIndex("GroupId", "UserId")+ .IsUnique();++ b.ToTable("GroupMembers");+ });+modelBuilder.Entity("AliasServerDb.Log", b =>{b.Property<int>("Id")@@ -716,94 +867,6 @@ namespace AliasServerDb.Migrationsb.ToTable("TaskRunnerJobs");});- modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>- {- b.Property<Guid>("Id")- .ValueGeneratedOnAdd()- .HasColumnType("uuid");-- b.Property<string>("Address")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-- b.Property<string>("AddressDomain")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-- b.Property<string>("AddressLocal")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-- b.Property<DateTime>("CreatedAt")- .HasColumnType("timestamp with time zone");-- b.Property<bool>("Disabled")- .HasColumnType("boolean");-- b.Property<Guid?>("EncryptionKeyId")- .HasColumnType("uuid");-- b.Property<DateTime>("UpdatedAt")- .HasColumnType("timestamp with time zone");-- b.Property<string>("UserId")- .HasMaxLength(255)- .HasColumnType("character varying(255)");-- b.HasKey("Id");-- b.HasIndex("Address")- .IsUnique();-- b.HasIndex("EncryptionKeyId");-- b.HasIndex("UserId", "CreatedAt");-- b.HasIndex("UserId", "Disabled");-- b.ToTable("UserEmailClaims");- });-- modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>- {- b.Property<Guid>("Id")- .ValueGeneratedOnAdd()- .HasColumnType("uuid");-- b.Property<DateTime>("CreatedAt")- .HasColumnType("timestamp with time zone");-- b.Property<bool>("IsPrimary")- .HasColumnType("boolean");-- b.Property<string>("PublicKey")- .IsRequired()- .HasMaxLength(2000)- .HasColumnType("character varying(2000)");-- b.Property<DateTime>("UpdatedAt")- .HasColumnType("timestamp with time zone");-- b.Property<string>("UserId")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-- b.Property<Guid?>("VaultManifestId")- .HasColumnType("uuid");-- b.HasKey("Id");-- b.HasIndex("VaultManifestId");-- b.HasIndex("UserId", "VaultManifestId", "IsPrimary");-- b.ToTable("UserEncryptionKeys");- });-modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>{b.Property<string>("Hash")@@ -1033,10 +1096,8 @@ namespace AliasServerDb.Migrations.HasMaxLength(255).HasColumnType("character varying(255)");- b.Property<string>("OwnerUserId")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");+ b.Property<Guid>("OwnerGroupId")+ .HasColumnType("uuid");b.Property<long>("RevisionNumber").HasColumnType("bigint");@@ -1070,9 +1131,9 @@ namespace AliasServerDb.Migrationsb.HasKey("ManifestId");- b.HasIndex("OwnerUserId")+ b.HasIndex("OwnerGroupId").IsUnique()- .HasDatabaseName("UX_VaultManifests_OwnerUserId_Root")+ .HasDatabaseName("UX_VaultManifests_OwnerGroupId_Root").HasFilter("\"IsRoot\"");b.ToTable("VaultManifests");@@ -1117,11 +1178,6 @@ namespace AliasServerDb.Migrations.HasMaxLength(64).HasColumnType("character varying(64)");- b.Property<string>("OwnerUserId")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-b.Property<string>("Salt").IsRequired().HasMaxLength(100)@@ -1151,8 +1207,6 @@ namespace AliasServerDb.Migrationsb.HasKey("ManifestId", "RevisionNumber");- b.HasIndex("OwnerUserId");-b.ToTable("VaultManifestsHistory", (string)null);});@@ -1301,6 +1355,17 @@ namespace AliasServerDb.Migrationsb.ToTable("UserTokens", (string)null);});+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.HasOne("AliasServerDb.Group", "PersonalGroup")+ .WithOne()+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")+ .OnDelete(DeleteBehavior.Restrict)+ .IsRequired();++ b.Navigation("PersonalGroup");+ });+modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User")@@ -1314,9 +1379,9 @@ namespace AliasServerDb.MigrationsmodelBuilder.Entity("AliasServerDb.Email", b =>{- b.HasOne("AliasServerDb.UserEncryptionKey", "EncryptionKey")+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey").WithMany("Emails")- .HasForeignKey("UserEncryptionKeyId")+ .HasForeignKey("EncryptionKeyId").OnDelete(DeleteBehavior.Cascade).IsRequired();@@ -1334,59 +1399,77 @@ namespace AliasServerDb.Migrationsb.Navigation("Email");});- modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>{- b.HasOne("AliasServerDb.AliasVaultUser", "User")+ b.HasOne("AliasServerDb.EncryptionKey", "EncryptionKey").WithMany()- .HasForeignKey("UserId")- .OnDelete(DeleteBehavior.Cascade);+ .HasForeignKey("EncryptionKeyId")+ .OnDelete(DeleteBehavior.Restrict);- b.Navigation("User");+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("EncryptionKey");++ b.Navigation("VaultManifest");});- modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User")- .WithMany()+ .WithMany("EncryptionKeys").HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade);+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade);+b.Navigation("User");++ b.Navigation("VaultManifest");});- modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ modelBuilder.Entity("AliasServerDb.GroupMember", b =>{- b.HasOne("AliasServerDb.UserEncryptionKey", "EncryptionKey")- .WithMany()- .HasForeignKey("EncryptionKeyId")- .OnDelete(DeleteBehavior.Restrict);+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany("Members")+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();b.HasOne("AliasServerDb.AliasVaultUser", "User")- .WithMany("EmailClaims")+ .WithMany().HasForeignKey("UserId")- .OnDelete(DeleteBehavior.SetNull);+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();- b.Navigation("EncryptionKey");+ b.Navigation("Group");b.Navigation("User");});- modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User")- .WithMany("EncryptionKeys")+ .WithMany().HasForeignKey("UserId")- .OnDelete(DeleteBehavior.Cascade)- .IsRequired();+ .OnDelete(DeleteBehavior.Cascade);- b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User").WithMany()- .HasForeignKey("VaultManifestId")+ .HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade);b.Navigation("User");-- b.Navigation("VaultManifest");});modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>@@ -1446,13 +1529,13 @@ namespace AliasServerDb.MigrationsmodelBuilder.Entity("AliasServerDb.VaultManifest", b =>{- b.HasOne("AliasServerDb.AliasVaultUser", "User")- .WithMany("VaultManifests")- .HasForeignKey("OwnerUserId")+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId").OnDelete(DeleteBehavior.Cascade).IsRequired();- b.Navigation("User");+ b.Navigation("OwnerGroup");});modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>@@ -1468,13 +1551,9 @@ namespace AliasServerDb.MigrationsmodelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>{- b.Navigation("EmailClaims");-b.Navigation("EncryptionKeys");b.Navigation("VaultKeys");-- b.Navigation("VaultManifests");});modelBuilder.Entity("AliasServerDb.Email", b =>@@ -1482,10 +1561,15 @@ namespace AliasServerDb.Migrationsb.Navigation("Attachments");});- modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ modelBuilder.Entity("AliasServerDb.EncryptionKey", b =>{b.Navigation("Emails");});++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });#pragma warning restore 612, 618}}