Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make sqlite-blob vault row fields nullable by design (#2159)
Leendert de Borst57147d82b3c5
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razorindex ea9b524ac..fc8d04ccb 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor@@ -396,7 +396,7 @@ elseUpdatedAt = x.UpdatedAt,Salt = x.Salt,Verifier = x.Verifier,- VaultBlob = string.Empty,+ VaultBlob = null,EncryptionType = x.EncryptionType,EncryptionSettings = x.EncryptionSettings,CredentialsCount = x.CredentialsCount,@@ -416,7 +416,7 @@ elseUpdatedAt = x.UpdatedAt,Salt = x.Salt,Verifier = x.Verifier,- VaultBlob = string.Empty,+ VaultBlob = null,EncryptionType = x.EncryptionType,EncryptionSettings = x.EncryptionSettings,CredentialsCount = x.CredentialsCount,diff --git a/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V1/VaultController.csindex 2a1d01607..5d8e33900 100644--- a/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs@@ -118,8 +118,8 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbContVault = new Shared.Models.WebApi.V1.Vault.Vault{Username = user.UserName!,- Blob = vault.VaultBlob,- Version = vault.Version,+ Blob = vault.VaultBlob ?? string.Empty,+ Version = vault.Version ?? string.Empty,CurrentRevisionNumber = vault.RevisionNumber,EncryptionPublicKey = string.Empty,CredentialsCount = 0,@@ -167,7 +167,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbContvar currentManifest = await context.VaultManifests.FirstAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);// Reject vaults with a version that is lower than the last vault version.- if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version))+ if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version ?? string.Empty)){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));}@@ -265,7 +265,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont// Check if the provided revision number is equal to the latest revision number.// If not, then the client is trying to update an older vault which we don't allow to prevent data loss.var currentManifest = await context.VaultManifests.FirstAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);- if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version))+ if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version ?? string.Empty)){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));}@@ -359,7 +359,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont.Select(x => new AliasServerDb.VaultManifestsHistory{ManifestId = x.ManifestId,- VaultBlob = string.Empty,+ VaultBlob = null,ManifestBlob = null,StorageFormat = x.StorageFormat,Version = x.Version,diff --git a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs b/apps/server/AliasVault.Api/Controllers/V2/AuthController.csindex e56fe12b2..fa8a3aeeb 100644--- a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs@@ -458,14 +458,13 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMManifestId = rootManifestId,IsRoot = true,OwnerGroupId = personalGroup.Id,- VaultBlob = string.Empty,StorageFormat = "sqlite-blob",Version = "0.0.0",RevisionNumber = 0,- Salt = createsVaultKey ? string.Empty : model.Salt,- Verifier = createsVaultKey ? string.Empty : model.Verifier,- EncryptionType = createsVaultKey ? string.Empty : model.EncryptionType,- EncryptionSettings = createsVaultKey ? string.Empty : model.EncryptionSettings,+ Salt = createsVaultKey ? null : model.Salt,+ Verifier = createsVaultKey ? null : model.Verifier,+ EncryptionType = createsVaultKey ? null : model.EncryptionType,+ EncryptionSettings = createsVaultKey ? null : model.EncryptionSettings,FileSize = 0,CreatedAt = timeProvider.UtcNow,UpdatedAt = timeProvider.UtcNow,diff --git a/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs b/apps/server/AliasVault.Api/Controllers/V2/SharingController.csindex f4b4d064e..ca4f18ff3 100644--- a/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs@@ -111,16 +111,10 @@ public class SharingController(IAliasServerDbContextFactory dbContextFactory, UsIsRoot = false,OwnerGroupId = me.PersonalGroupId,Name = model.Name,- VaultBlob = string.Empty,StorageFormat = ManifestFormat,ManifestBlob = model.ManifestBlob,ManifestCiphertextHash = model.ManifestCiphertextHash,- Version = string.Empty,RevisionNumber = 1,- Salt = string.Empty,- Verifier = string.Empty,- EncryptionType = string.Empty,- EncryptionSettings = string.Empty,FileSize = FileHelper.Base64StringToKilobytes(model.ManifestBlob),Client = clientHeader,CreatedAt = timeProvider.UtcNow,diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.csindex c36fc2830..0d86bca13 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs@@ -431,13 +431,13 @@ public class VaultController(var archivedRevision = VaultManifestsHistory.CreateFrom(row);context.VaultManifestsHistory.Add(archivedRevision);- row.VaultBlob = string.Empty;+ row.VaultBlob = null;row.StorageFormat = ManifestFormat;row.ManifestBlob = mw.ManifestBlob;row.ManifestCiphertextHash = mw.ManifestCiphertextHash;- // Manifest revisions carry no data-model version, so we make it empty instead.- row.Version = string.Empty;+ // Manifest revisions carry no data-model version, so we null it instead.+ row.Version = null;row.RevisionNumber = mw.CurrentRevision + 1;row.FileSize = FileHelper.Base64StringToKilobytes(mw.ManifestBlob);row.CredentialsCount = mw.CredentialsCount;@@ -499,10 +499,10 @@ public class VaultController(UpdatedAt = timeProvider.UtcNow,});- row.Salt = string.Empty;- row.Verifier = string.Empty;- row.EncryptionType = string.Empty;- row.EncryptionSettings = string.Empty;+ row.Salt = null;+ row.Verifier = null;+ row.EncryptionType = null;+ row.EncryptionSettings = null;}}@@ -1025,7 +1025,7 @@ public class VaultController(.Select(x => new VaultManifestsHistory{ManifestId = x.ManifestId,- VaultBlob = string.Empty,+ VaultBlob = null,ManifestBlob = null,StorageFormat = x.StorageFormat,Version = x.Version,diff --git a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs b/apps/server/AliasVault.Api/Helpers/AuthHelper.csindex 8cd4b7001..6ca429c00 100644--- a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/AuthHelper.cs@@ -90,7 +90,8 @@ public static class AuthHelper.Select(x => new { x.Salt, x.Verifier, x.EncryptionType, x.EncryptionSettings }).FirstAsync();- return (latestVault.Salt, latestVault.Verifier, latestVault.EncryptionType, latestVault.EncryptionSettings);+ // The SRP columns are null once a user moved to the unlock-key model, which the branch above already covers.+ return (latestVault.Salt ?? string.Empty, latestVault.Verifier ?? string.Empty, latestVault.EncryptionType ?? string.Empty, latestVault.EncryptionSettings ?? string.Empty);}/// <summary>diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.Designer.csnew file mode 100644index 000000000..88f55846d--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.Designer.cs@@ -0,0 +1,1644 @@+// <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("20260807192839_MakeLegacyManifestColumnsNullable")]+ partial class MakeLegacyManifestColumnsNullable+ {+ /// <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<DateTime?>("LastActivityDate")+ .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<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<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<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "Disabled");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailsReceived")+ .HasColumnType("integer");++ b.Property<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ 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<Guid?>("GroupId")+ .HasColumnType("uuid");++ 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<int>("WindowSeconds")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("Tier");++ 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.UserGrantKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedPrivateKey")+ .IsRequired()+ .HasMaxLength(4000)+ .HasColumnType("character varying(4000)");++ 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.HasKey("Id");++ b.HasIndex("UserId")+ .IsUnique()+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")+ .HasFilter("\"IsPrimary\"");++ b.ToTable("UserGrantKeys");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .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", "Type")+ .IsUnique()+ .HasDatabaseName("UX_UserUnlockKeys_UserId_Type");++ b.ToTable("UserUnlockKeys");+ });++ 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.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")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .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")+ .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")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .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.VaultManifestAccessKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedVek")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("UserGrantKeyId")+ .HasColumnType("uuid");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("UserGrantKeyId");++ b.HasIndex("VaultManifestId")+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");++ b.HasIndex("UserId", "Type", "VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest");++ b.ToTable("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", 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<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")+ .HasFilter("\"IsPrimary\"");++ b.HasIndex("VaultManifestId", "IsPrimary");++ b.ToTable("VaultManifestDeliveryKeys");+ });++ 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")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .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")+ .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")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .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.VaultManifestDeliveryKey", "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.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ 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.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Group");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ 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.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("OwnerGroup");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")+ .WithMany()+ .HasForeignKey("UserGrantKeyId")+ .OnDelete(DeleteBehavior.SetNull);++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifestAccessKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");++ b.Navigation("UserGrantKey");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("VaultManifest");+ });++ 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("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.csnew file mode 100644index 000000000..e71dd699a--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807192839_MakeLegacyManifestColumnsNullable.cs@@ -0,0 +1,302 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class MakeLegacyManifestColumnsNullable : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.AlterColumn<string>(+ name: "Version",+ table: "VaultManifestsHistory",+ type: "character varying(255)",+ maxLength: 255,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(255)",+ oldMaxLength: 255);++ migrationBuilder.AlterColumn<string>(+ name: "Verifier",+ table: "VaultManifestsHistory",+ type: "character varying(1000)",+ maxLength: 1000,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(1000)",+ oldMaxLength: 1000);++ migrationBuilder.AlterColumn<string>(+ name: "VaultBlob",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ migrationBuilder.AlterColumn<string>(+ name: "Salt",+ table: "VaultManifestsHistory",+ type: "character varying(100)",+ maxLength: 100,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(100)",+ oldMaxLength: 100);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionType",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionSettings",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ migrationBuilder.AlterColumn<string>(+ name: "Version",+ table: "VaultManifests",+ type: "character varying(255)",+ maxLength: 255,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(255)",+ oldMaxLength: 255);++ migrationBuilder.AlterColumn<string>(+ name: "Verifier",+ table: "VaultManifests",+ type: "character varying(1000)",+ maxLength: 1000,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(1000)",+ oldMaxLength: 1000);++ migrationBuilder.AlterColumn<string>(+ name: "VaultBlob",+ table: "VaultManifests",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ migrationBuilder.AlterColumn<string>(+ name: "Salt",+ table: "VaultManifests",+ type: "character varying(100)",+ maxLength: 100,+ nullable: true,+ oldClrType: typeof(string),+ oldType: "character varying(100)",+ oldMaxLength: 100);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionType",+ table: "VaultManifests",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionSettings",+ table: "VaultManifests",+ type: "text",+ nullable: true,+ oldClrType: typeof(string),+ oldType: "text");++ // Replace the old empty-string sentinel with NULL so the columns read uniformly: a NULL VaultBlob/Version+ // means the revision is manifest-v1, and NULL SRP columns mean the credentials moved to the unlock-key+ // model. Only legacy sqlite-blob revisions keep values here.+ migrationBuilder.Sql("""+ UPDATE "VaultManifests" SET+ "VaultBlob" = NULLIF("VaultBlob", ''),+ "Version" = NULLIF("Version", ''),+ "Salt" = NULLIF("Salt", ''),+ "Verifier" = NULLIF("Verifier", ''),+ "EncryptionType" = NULLIF("EncryptionType", ''),+ "EncryptionSettings" = NULLIF("EncryptionSettings", '');+ """);++ migrationBuilder.Sql("""+ UPDATE "VaultManifestsHistory" SET+ "VaultBlob" = NULLIF("VaultBlob", ''),+ "Version" = NULLIF("Version", ''),+ "Salt" = NULLIF("Salt", ''),+ "Verifier" = NULLIF("Verifier", ''),+ "EncryptionType" = NULLIF("EncryptionType", ''),+ "EncryptionSettings" = NULLIF("EncryptionSettings", '');+ """);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ // Restore the empty-string sentinel first: the columns below go back to NOT NULL.+ migrationBuilder.Sql("""+ UPDATE "VaultManifests" SET+ "VaultBlob" = COALESCE("VaultBlob", ''),+ "Version" = COALESCE("Version", ''),+ "Salt" = COALESCE("Salt", ''),+ "Verifier" = COALESCE("Verifier", ''),+ "EncryptionType" = COALESCE("EncryptionType", ''),+ "EncryptionSettings" = COALESCE("EncryptionSettings", '');+ """);++ migrationBuilder.Sql("""+ UPDATE "VaultManifestsHistory" SET+ "VaultBlob" = COALESCE("VaultBlob", ''),+ "Version" = COALESCE("Version", ''),+ "Salt" = COALESCE("Salt", ''),+ "Verifier" = COALESCE("Verifier", ''),+ "EncryptionType" = COALESCE("EncryptionType", ''),+ "EncryptionSettings" = COALESCE("EncryptionSettings", '');+ """);++ migrationBuilder.AlterColumn<string>(+ name: "Version",+ table: "VaultManifestsHistory",+ type: "character varying(255)",+ maxLength: 255,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(255)",+ oldMaxLength: 255,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "Verifier",+ table: "VaultManifestsHistory",+ type: "character varying(1000)",+ maxLength: 1000,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(1000)",+ oldMaxLength: 1000,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "VaultBlob",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "Salt",+ table: "VaultManifestsHistory",+ type: "character varying(100)",+ maxLength: 100,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(100)",+ oldMaxLength: 100,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionType",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionSettings",+ table: "VaultManifestsHistory",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "Version",+ table: "VaultManifests",+ type: "character varying(255)",+ maxLength: 255,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(255)",+ oldMaxLength: 255,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "Verifier",+ table: "VaultManifests",+ type: "character varying(1000)",+ maxLength: 1000,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(1000)",+ oldMaxLength: 1000,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "VaultBlob",+ table: "VaultManifests",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "Salt",+ table: "VaultManifests",+ type: "character varying(100)",+ maxLength: 100,+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "character varying(100)",+ oldMaxLength: 100,+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionType",+ table: "VaultManifests",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);++ migrationBuilder.AlterColumn<string>(+ name: "EncryptionSettings",+ table: "VaultManifests",+ type: "text",+ nullable: false,+ defaultValue: "",+ oldClrType: typeof(string),+ oldType: "text",+ oldNullable: true);+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex ebb7bcf79..a4ac1b5b1 100644--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -1045,11 +1045,9 @@ namespace AliasServerDb.Migrations.HasColumnType("integer");b.Property<string>("EncryptionSettings")- .IsRequired().HasColumnType("text");b.Property<string>("EncryptionType")- .IsRequired().HasColumnType("text");b.Property<int>("FileSize")@@ -1076,7 +1074,6 @@ namespace AliasServerDb.Migrations.HasColumnType("bigint");b.Property<string>("Salt")- .IsRequired().HasMaxLength(100).HasColumnType("character varying(100)");@@ -1089,16 +1086,13 @@ namespace AliasServerDb.Migrations.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)");@@ -1224,11 +1218,9 @@ namespace AliasServerDb.Migrations.HasColumnType("integer");b.Property<string>("EncryptionSettings")- .IsRequired().HasColumnType("text");b.Property<string>("EncryptionType")- .IsRequired().HasColumnType("text");b.Property<int>("FileSize")@@ -1242,7 +1234,6 @@ namespace AliasServerDb.Migrations.HasColumnType("character varying(64)");b.Property<string>("Salt")- .IsRequired().HasMaxLength(100).HasColumnType("character varying(100)");@@ -1255,16 +1246,13 @@ namespace AliasServerDb.Migrations.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)");diff --git a/apps/server/Databases/AliasServerDb/VaultManifestBase.cs b/apps/server/Databases/AliasServerDb/VaultManifestBase.csindex 2cf25bfdf..1a16a75f7 100644--- a/apps/server/Databases/AliasServerDb/VaultManifestBase.cs+++ b/apps/server/Databases/AliasServerDb/VaultManifestBase.cs@@ -11,13 +11,19 @@ using System.ComponentModel.DataAnnotations;/// <summary>/// Shared revision payload columns for a vault manifest. <see cref="VaultManifest"/> holds the current revision of/// each logical manifest (one row per manifest); <see cref="VaultManifestsHistory"/> holds superseded revisions.+/// <para>+/// The columns the manifest-v1 format no longer uses are nullable so null reads as "not applicable to this revision":+/// a revision with a null <see cref="VaultBlob"/>/<see cref="Version"/> is manifest-v1, and null SRP columns mean the+/// login credentials moved to the unlock-key model. Only legacy sqlite-blob revisions carry values there.+/// </para>/// </summary>public abstract class VaultManifestBase : IVaultRevision{/// <summary>- /// Gets or sets the encrypted vault blob (only used by legacy sqlite-blob format). Not used anymore in new format.+ /// Gets or sets the encrypted vault blob. Only the legacy sqlite-blob format populates this; on manifest-v1+ /// revisions it is null. TODO: remove this column once the legacy model is fully deprecated./// </summary>- public required string VaultBlob { get; set; }+ public string? VaultBlob { get; set; }/// <summary>/// Gets or sets the storage format identifier: "sqlite-blob" (legacy v1) or "manifest-v1" (v2).@@ -38,13 +44,12 @@ public abstract class VaultManifestBase : IVaultRevisionpublic string? ManifestCiphertextHash { get; set; }/// <summary>- /// Gets or sets the vault data model version. Only the legacy sqlite-blob format populates this; manifest-v1- /// revisions leave it empty as the version is carried inside the manifest naming scheme instead. Kept so- /// not-yet-migrated users' manifests retain their historic value. TODO: remove this column once the legacy- /// model is fully deprecated.+ /// Gets or sets the vault data model version. Only the legacy sqlite-blob format populates this; on manifest-v1+ /// revisions it is null as the version is carried inside the manifest itself instead. Kept so not-yet-migrated+ /// users' manifests retain their historic value. TODO: remove this column once the legacy model is fully deprecated./// </summary>[StringLength(255)]- public required string Version { get; set; }+ public string? Version { get; set; }/// <summary>/// Gets or sets the revision number of the vault manifest. This number is incremented with each change.@@ -61,18 +66,18 @@ public abstract class VaultManifestBase : IVaultRevision/// Gets or sets the salt used for SRP authentication. On the legacy model the login/// credentials are stored with the vault manifest because the manifest is encrypted with the key derived from/// the user's password, keeping login and vault password in sync across backup restores. Once a user has a VaultManifestAccessKey- /// the SRP credentials live there instead and this column is empty on current revisions (history revisions keep+ /// the SRP credentials live there instead and this column is null on current revisions (history revisions keep/// their at-the-time values). TODO: remove this column once the legacy model is fully deprecated./// </summary>[StringLength(100)]- public required string Salt { get; set; }+ public string? Salt { get; set; }/// <summary>/// Gets or sets the verifier used for SRP authentication. See the remarks on/// <see cref="Salt"/> for how this relates to the VaultManifestAccessKey model. TODO: remove this column once the legacy model is fully deprecated./// </summary>[StringLength(1000)]- public required string Verifier { get; set; }+ public string? Verifier { get; set; }/// <summary>/// Gets or sets the number of credentials stored in the vault. This anonymous data is used in case a vault back-up@@ -90,13 +95,13 @@ public abstract class VaultManifestBase : IVaultRevision/// Gets or sets the encryption type. See remarks on <see cref="Salt"/> for how this relates to the VaultManifestAccessKey model./// TODO: remove this column once the legacy model is fully deprecated./// </summary>- public required string EncryptionType { get; set; }+ public string? EncryptionType { get; set; }/// <summary>/// Gets or sets the encryption settings. See remarks on <see cref="Salt"/> for how this relates to the VaultManifestAccessKey model./// TODO: remove this column once the legacy model is fully deprecated./// </summary>- public required string EncryptionSettings { get; set; }+ public string? EncryptionSettings { get; set; }/// <summary>/// Gets or sets the client that created the vault.diff --git a/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs b/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.csindex 500dacfdb..c5bb23da8 100644--- a/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs+++ b/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs@@ -118,6 +118,31 @@ public class GeneralRetentionTests});}+ /// <summary>+ /// Test that the DbVersionRetentionRule treats manifest-v1 revisions (null Version) as their own group, so the+ /// last legacy sqlite-blob revision before a user's migration is still retained next to the manifest revisions.+ /// </summary>+ [Test]+ public void VersionRetentionRuleTreatsNullVersionAsOwnGroupTest()+ {+ var revisions = new List<VaultManifestsHistory>(testVaults)+ {+ new VaultManifestsHistory { Version = null, UpdatedAt = new DateTime(2023, 6, 1, 10, 0, 0), StorageFormat = "manifest-v1", RevisionNumber = 10 },+ new VaultManifestsHistory { Version = null, UpdatedAt = new DateTime(2023, 6, 1, 11, 0, 0), StorageFormat = "manifest-v1", RevisionNumber = 11 },+ };++ var rule = new DbVersionRetentionRule { VersionsToKeep = 2 };+ var result = rule.ApplyRule([.. revisions], now).ToList();++ // The latest manifest-v1 revision plus the latest revision of the newest legacy version.+ Assert.Multiple(() =>+ {+ Assert.That(result, Has.Count.EqualTo(2));+ Assert.That(result[0].RevisionNumber, Is.EqualTo(11));+ Assert.That(result[1].UpdatedAt, Is.EqualTo(new DateTime(2023, 5, 31, 12, 0, 0)));+ });+ }+/// <summary>/// Test the LoginCredentialRetentionRule./// </summary>