Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Rebuild server EF migrations (#2159)

Leendert de Borstbc96b2ff0070
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.cs
deleted file mode 100644
index 605209034..000000000
--- a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.cs
+++ /dev/null
@@ -1,1182 +0,0 @@
-// <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("20260611122937_AddVaultV2Storage")]
- partial class AddVaultV2Storage
- {
- /// <inheritdoc />
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "10.0.6")
- .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<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.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<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<Guid>("UserEncryptionKeyId")
- .HasMaxLength(255)
- .HasColumnType("uuid");
-
- b.Property<bool>("Visible")
- .HasColumnType("boolean");
-
- b.HasKey("Id");
-
- b.HasIndex("Date");
-
- b.HasIndex("DateSystem");
-
- b.HasIndex("PushNotificationSent");
-
- b.HasIndex("UserEncryptionKeyId");
-
- 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.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.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.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<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("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.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("UserEncryptionKeys");
- });
-
- modelBuilder.Entity("AliasServerDb.Vault", b =>
- {
- b.Property<Guid>("Id")
- .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<string>("ManifestBlob")
- .HasColumnType("text");
-
- b.Property<string>("ManifestCiphertextHash")
- .HasMaxLength(64)
- .HasColumnType("character varying(64)");
-
- 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>("UserId")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("character varying(255)");
-
- 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("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("Vaults");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
- {
- b.Property<string>("Hash")
- .HasMaxLength(64)
- .HasColumnType("character varying(64)");
-
- b.Property<string>("UserId")
- .HasMaxLength(255)
- .HasColumnType("character varying(255)");
-
- b.Property<DateTime>("CreatedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property<byte[]>("EncryptedData")
- .IsRequired()
- .HasColumnType("bytea");
-
- b.Property<string>("Kind")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property<DateTime>("LastReferencedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property<int>("SizeBytes")
- .HasColumnType("integer");
-
- b.HasKey("Hash", "UserId");
-
- b.HasIndex("UserId", "Kind");
-
- b.ToTable("VaultBlobObjects");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
- {
- b.Property<Guid>("VaultId")
- .HasColumnType("uuid");
-
- b.Property<string>("BlobHash")
- .HasMaxLength(64)
- .HasColumnType("character varying(64)");
-
- b.HasKey("VaultId", "BlobHash");
-
- b.ToTable("VaultBlobReferences");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- 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<string>("Kind")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
-
- b.Property<long>("RevisionNumber")
- .HasColumnType("bigint");
-
- 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", "Kind", "RevisionNumber")
- .IsUnique();
-
- b.ToTable("VaultDataBuckets");
- });
-
- 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.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.UserEncryptionKey", "EncryptionKey")
- .WithMany("Emails")
- .HasForeignKey("UserEncryptionKeyId")
- .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.MobileLoginRequest", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany("EmailClaims")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.SetNull);
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany("EncryptionKeys")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.Vault", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany("Vaults")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
- {
- b.HasOne("AliasServerDb.Vault", "Vault")
- .WithMany()
- .HasForeignKey("VaultId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Vault");
- });
-
- modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
- {
- b.HasOne("AliasServerDb.AliasVaultUser", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
- {
- b.Navigation("EmailClaims");
-
- b.Navigation("EncryptionKeys");
-
- b.Navigation("Vaults");
- });
-
- modelBuilder.Entity("AliasServerDb.Email", b =>
- {
- b.Navigation("Attachments");
- });
-
- modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>
- {
- b.Navigation("Emails");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.cs
deleted file mode 100644
index e5fa5f96c..000000000
--- a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace AliasServerDb.Migrations
-{
- /// <inheritdoc />
- public partial class AddVaultV2Storage : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<string>(
- name: "ManifestBlob",
- table: "Vaults",
- type: "text",
- nullable: true);
-
- migrationBuilder.AddColumn<string>(
- name: "ManifestCiphertextHash",
- table: "Vaults",
- type: "character varying(64)",
- maxLength: 64,
- nullable: true);
-
- // Add nullable, backfill every existing (legacy) vault explicitly, then enforce NOT NULL. This avoids
- // leaving a persistent column default — the storage format is always set explicitly by the app.
- migrationBuilder.AddColumn<string>(
- name: "StorageFormat",
- table: "Vaults",
- type: "character varying(20)",
- maxLength: 20,
- nullable: true);
-
- migrationBuilder.Sql("UPDATE \"Vaults\" SET \"StorageFormat\" = 'sqlite-blob' WHERE \"StorageFormat\" IS NULL;");
-
- migrationBuilder.AlterColumn<string>(
- name: "StorageFormat",
- table: "Vaults",
- type: "character varying(20)",
- maxLength: 20,
- nullable: false,
- oldClrType: typeof(string),
- oldType: "character varying(20)",
- oldMaxLength: 20,
- oldNullable: true);
-
- migrationBuilder.CreateTable(
- name: "VaultBlobObjects",
- columns: table => new
- {
- Hash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
- UserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
- Kind = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
- EncryptedData = table.Column<byte[]>(type: "bytea", nullable: false),
- SizeBytes = table.Column<int>(type: "integer", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
- LastReferencedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_VaultBlobObjects", x => new { x.Hash, x.UserId });
- table.ForeignKey(
- name: "FK_VaultBlobObjects_AliasVaultUsers_UserId",
- column: x => x.UserId,
- principalTable: "AliasVaultUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "VaultBlobReferences",
- columns: table => new
- {
- VaultId = table.Column<Guid>(type: "uuid", nullable: false),
- BlobHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_VaultBlobReferences", x => new { x.VaultId, x.BlobHash });
- table.ForeignKey(
- name: "FK_VaultBlobReferences_Vaults_VaultId",
- column: x => x.VaultId,
- principalTable: "Vaults",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "VaultDataBuckets",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- UserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
- Kind = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
- EncryptedData = table.Column<string>(type: "text", nullable: false),
- RevisionNumber = table.Column<long>(type: "bigint", nullable: false),
- CiphertextHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
- CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
- UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_VaultDataBuckets", x => x.Id);
- table.ForeignKey(
- name: "FK_VaultDataBuckets_AliasVaultUsers_UserId",
- column: x => x.UserId,
- principalTable: "AliasVaultUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_VaultBlobObjects_UserId_Kind",
- table: "VaultBlobObjects",
- columns: new[] { "UserId", "Kind" });
-
- migrationBuilder.CreateIndex(
- name: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber",
- table: "VaultDataBuckets",
- columns: new[] { "UserId", "Kind", "RevisionNumber" },
- unique: true);
- }
-
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "VaultBlobObjects");
-
- migrationBuilder.DropTable(
- name: "VaultBlobReferences");
-
- migrationBuilder.DropTable(
- name: "VaultDataBuckets");
-
- migrationBuilder.DropColumn(
- name: "ManifestBlob",
- table: "Vaults");
-
- migrationBuilder.DropColumn(
- name: "ManifestCiphertextHash",
- table: "Vaults");
-
- migrationBuilder.DropColumn(
- name: "StorageFormat",
- table: "Vaults");
- }
- }
-}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.cs
deleted file mode 100644
index 4a5b400a3..000000000
--- a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace AliasServerDb.Migrations
-{
- /// <inheritdoc />
- public partial class RenameVaultToVaultManifest : Migration
- {
- // NOTE: EF scaffolded the "Vaults" rename as DROP TABLE + CREATE TABLE "VaultManifests", which would destroy
- // every user's vault. We rewrite that part as an in-place rename so existing rows are preserved. The
- // VaultDataBuckets / VaultBlobObjects / VaultBlobReferences renames were scaffolded correctly (those tables
- // are new this release) and are kept. "Vault" no longer maps to a table — a user's logical vault is assembled
- // from one or more VaultManifests (revisions grouped by ManifestId) plus their buckets and blobs.
- // UserId -> OwnerUserId everywhere: ownership is now explicit (R2 sharing lets users access manifests/blobs
- // owned by someone else).
- // "Kind" -> "Category" everywhere (manifest, data bucket, blob object): one consistent term for the
- // discriminator instead of mixing "Kind"/"Category".
-
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- // Drop the FKs that reference the columns/table we are about to rename; re-added with new names at the end.
- // (Dropping a constraint is metadata-only — no row data is touched.)
- migrationBuilder.DropForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_UserId", table: "VaultBlobObjects");
- migrationBuilder.DropForeignKey(name: "FK_VaultBlobReferences_Vaults_VaultId", table: "VaultBlobReferences");
- migrationBuilder.DropForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_UserId", table: "VaultDataBuckets");
-
- // VaultDataBuckets: owner + per-revision PK + category column + index renames.
- migrationBuilder.RenameColumn(name: "UserId", table: "VaultDataBuckets", newName: "OwnerUserId");
- migrationBuilder.RenameColumn(name: "Id", table: "VaultDataBuckets", newName: "RevisionId");
- migrationBuilder.RenameColumn(name: "Kind", table: "VaultDataBuckets", newName: "Category");
- migrationBuilder.RenameIndex(name: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber", table: "VaultDataBuckets", newName: "IX_VaultDataBuckets_OwnerUserId_Category_RevisionNumber");
-
- // VaultBlobObjects: owner column + blob category column + index rename.
- migrationBuilder.RenameColumn(name: "UserId", table: "VaultBlobObjects", newName: "OwnerUserId");
- migrationBuilder.RenameColumn(name: "Kind", table: "VaultBlobObjects", newName: "Category");
- migrationBuilder.RenameIndex(name: "IX_VaultBlobObjects_UserId_Kind", table: "VaultBlobObjects", newName: "IX_VaultBlobObjects_OwnerUserId_Category");
-
- // VaultBlobReferences: the FK column now points at a manifest revision.
- migrationBuilder.RenameColumn(name: "VaultId", table: "VaultBlobReferences", newName: "ManifestRevisionId");
-
- // Vaults -> VaultManifests, IN PLACE (preserves every existing vault row). Postgres keeps constraints/
- // indexes under their old names across a rename, so rename them explicitly to match the EF model.
- migrationBuilder.RenameTable(name: "Vaults", newName: "VaultManifests");
- migrationBuilder.RenameColumn(name: "Id", table: "VaultManifests", newName: "RevisionId");
- migrationBuilder.RenameColumn(name: "UserId", table: "VaultManifests", newName: "OwnerUserId");
- migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_Vaults"" TO ""PK_VaultManifests"";");
- migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_Vaults_AliasVaultUsers_UserId"" TO ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"";");
- migrationBuilder.RenameIndex(name: "IX_Vaults_UserId", table: "VaultManifests", newName: "IX_VaultManifests_OwnerUserId");
-
- // New manifest-lineage columns. Add nullable, backfill every existing row, then enforce NOT NULL — no
- // persisted column default (the app always sets these explicitly).
- migrationBuilder.AddColumn<Guid>(name: "ManifestId", table: "VaultManifests", type: "uuid", nullable: true);
- migrationBuilder.AddColumn<string>(name: "Category", table: "VaultManifests", type: "character varying(20)", maxLength: 20, nullable: true);
-
- // Every existing revision belongs to the owner's single "Main" manifest. All of an owner's rows must share
- // ONE ManifestId (revisions of the same logical manifest), so assign one new GUID per distinct owner.
- migrationBuilder.Sql(@"UPDATE ""VaultManifests"" v SET ""ManifestId"" = sub.gid FROM (SELECT DISTINCT ""OwnerUserId"", gen_random_uuid() AS gid FROM ""VaultManifests"") sub WHERE v.""OwnerUserId"" = sub.""OwnerUserId"";");
- migrationBuilder.Sql(@"UPDATE ""VaultManifests"" SET ""Category"" = 'Main' WHERE ""Category"" IS NULL;");
-
- migrationBuilder.AlterColumn<Guid>(
- name: "ManifestId",
- table: "VaultManifests",
- type: "uuid",
- nullable: false,
- oldClrType: typeof(Guid),
- oldType: "uuid",
- oldNullable: true);
- migrationBuilder.AlterColumn<string>(
- name: "Category",
- table: "VaultManifests",
- type: "character varying(20)",
- maxLength: 20,
- nullable: false,
- oldClrType: typeof(string),
- oldType: "character varying(20)",
- oldMaxLength: 20,
- oldNullable: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_VaultManifests_ManifestId_RevisionNumber",
- table: "VaultManifests",
- columns: new[] { "ManifestId", "RevisionNumber" });
-
- // Re-add the FKs dropped above, now with their new names/targets.
- migrationBuilder.AddForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_OwnerUserId", table: "VaultBlobObjects", column: "OwnerUserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(name: "FK_VaultBlobReferences_VaultManifests_ManifestRevisionId", table: "VaultBlobReferences", column: "ManifestRevisionId", principalTable: "VaultManifests", principalColumn: "RevisionId", onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_OwnerUserId", table: "VaultDataBuckets", column: "OwnerUserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
- }
-
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_OwnerUserId", table: "VaultBlobObjects");
- migrationBuilder.DropForeignKey(name: "FK_VaultBlobReferences_VaultManifests_ManifestRevisionId", table: "VaultBlobReferences");
- migrationBuilder.DropForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_OwnerUserId", table: "VaultDataBuckets");
-
- // Reverse VaultManifests -> Vaults.
- migrationBuilder.DropIndex(name: "IX_VaultManifests_ManifestId_RevisionNumber", table: "VaultManifests");
- migrationBuilder.DropColumn(name: "Category", table: "VaultManifests");
- migrationBuilder.DropColumn(name: "ManifestId", table: "VaultManifests");
- migrationBuilder.RenameIndex(name: "IX_VaultManifests_OwnerUserId", table: "VaultManifests", newName: "IX_Vaults_UserId");
- migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"" TO ""FK_Vaults_AliasVaultUsers_UserId"";");
- migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_VaultManifests"" TO ""PK_Vaults"";");
- migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultManifests", newName: "UserId");
- migrationBuilder.RenameColumn(name: "RevisionId", table: "VaultManifests", newName: "Id");
- migrationBuilder.RenameTable(name: "VaultManifests", newName: "Vaults");
-
- // Reverse VaultBlobReferences.
- migrationBuilder.RenameColumn(name: "ManifestRevisionId", table: "VaultBlobReferences", newName: "VaultId");
-
- // Reverse VaultBlobObjects.
- migrationBuilder.RenameIndex(name: "IX_VaultBlobObjects_OwnerUserId_Category", table: "VaultBlobObjects", newName: "IX_VaultBlobObjects_UserId_Kind");
- migrationBuilder.RenameColumn(name: "Category", table: "VaultBlobObjects", newName: "Kind");
- migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultBlobObjects", newName: "UserId");
-
- // Reverse VaultDataBuckets.
- migrationBuilder.RenameIndex(name: "IX_VaultDataBuckets_OwnerUserId_Category_RevisionNumber", table: "VaultDataBuckets", newName: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber");
- migrationBuilder.RenameColumn(name: "Category", table: "VaultDataBuckets", newName: "Kind");
- migrationBuilder.RenameColumn(name: "RevisionId", table: "VaultDataBuckets", newName: "Id");
- migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultDataBuckets", newName: "UserId");
-
- // Re-add the original FKs.
- migrationBuilder.AddForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_UserId", table: "VaultBlobObjects", column: "UserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(name: "FK_VaultBlobReferences_Vaults_VaultId", table: "VaultBlobReferences", column: "VaultId", principalTable: "Vaults", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_UserId", table: "VaultDataBuckets", column: "UserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
- }
- }
-}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.Designer.cs
similarity index 94%
rename from apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.cs
rename to apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.Designer.cs
index 4faa3f77c..5ab940dcd 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.Designer.cs
@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace AliasServerDb.Migrations
{
[DbContext(typeof(AliasServerDbContext))]
- [Migration("20260611212909_RenameVaultToVaultManifest")]
- partial class RenameVaultToVaultManifest
+ [Migration("20260719211030_AddVaultV2Storage")]
+ partial class AddVaultV2Storage
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -604,6 +604,65 @@ namespace AliasServerDb.Migrations
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")
@@ -699,6 +758,8 @@ namespace AliasServerDb.Migrations
b.HasIndex("Address")
.IsUnique();
+ b.HasIndex("UserId", "CreatedAt");
+
b.HasIndex("UserId", "Disabled");
b.ToTable("UserEmailClaims");
@@ -1103,6 +1164,16 @@ namespace AliasServerDb.Migrations
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.UserEmailClaim", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", "User")
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.cs b/apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.cs
new file mode 100644
index 000000000..508101de0
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260719211030_AddVaultV2Storage.cs
@@ -0,0 +1,179 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class AddVaultV2Storage : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ // --- Transform the existing "Vaults" table into "VaultManifests" IN PLACE (preserves every vault row) ---
+
+ // Storage-format columns. Add nullable, backfill every existing (legacy) vault explicitly, then enforce
+ // NOT NULL. This avoids leaving a persistent column default — the storage format is always set explicitly
+ // by the app.
+ migrationBuilder.AddColumn<string>(name: "ManifestBlob", table: "Vaults", type: "text", nullable: true);
+ migrationBuilder.AddColumn<string>(name: "ManifestCiphertextHash", table: "Vaults", type: "character varying(64)", maxLength: 64, nullable: true);
+ migrationBuilder.AddColumn<string>(name: "StorageFormat", table: "Vaults", type: "character varying(20)", maxLength: 20, nullable: true);
+ migrationBuilder.Sql("UPDATE \"Vaults\" SET \"StorageFormat\" = 'sqlite-blob' WHERE \"StorageFormat\" IS NULL;");
+ migrationBuilder.AlterColumn<string>(
+ name: "StorageFormat",
+ table: "Vaults",
+ type: "character varying(20)",
+ maxLength: 20,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "character varying(20)",
+ oldMaxLength: 20,
+ oldNullable: true);
+
+ // Rename "Vaults" -> "VaultManifests" in place, including constraints and indexes.
+ migrationBuilder.RenameTable(name: "Vaults", newName: "VaultManifests");
+ migrationBuilder.RenameColumn(name: "Id", table: "VaultManifests", newName: "RevisionId");
+ migrationBuilder.RenameColumn(name: "UserId", table: "VaultManifests", newName: "OwnerUserId");
+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_Vaults"" TO ""PK_VaultManifests"";");
+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_Vaults_AliasVaultUsers_UserId"" TO ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"";");
+ migrationBuilder.RenameIndex(name: "IX_Vaults_UserId", table: "VaultManifests", newName: "IX_VaultManifests_OwnerUserId");
+
+ // New manifest-lineage columns. Add nullable, backfill every existing row, then enforce NOT NULL.
+ migrationBuilder.AddColumn<Guid>(name: "ManifestId", table: "VaultManifests", type: "uuid", nullable: true);
+ migrationBuilder.AddColumn<string>(name: "Category", table: "VaultManifests", type: "character varying(20)", maxLength: 20, nullable: true);
+
+ // Every existing revision belongs to the owner's single "Main" manifest. All of an owner's rows must share
+ // ONE ManifestId (revisions of the same logical manifest), so assign one new GUID per distinct owner.
+ migrationBuilder.Sql(@"UPDATE ""VaultManifests"" v SET ""ManifestId"" = sub.gid FROM (SELECT DISTINCT ""OwnerUserId"", gen_random_uuid() AS gid FROM ""VaultManifests"") sub WHERE v.""OwnerUserId"" = sub.""OwnerUserId"";");
+ migrationBuilder.Sql(@"UPDATE ""VaultManifests"" SET ""Category"" = 'Main' WHERE ""Category"" IS NULL;");
+
+ migrationBuilder.AlterColumn<Guid>(
+ name: "ManifestId",
+ table: "VaultManifests",
+ type: "uuid",
+ nullable: false,
+ oldClrType: typeof(Guid),
+ oldType: "uuid",
+ oldNullable: true);
+ migrationBuilder.AlterColumn<string>(
+ name: "Category",
+ table: "VaultManifests",
+ type: "character varying(20)",
+ maxLength: 20,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "character varying(20)",
+ oldMaxLength: 20,
+ oldNullable: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_VaultManifests_ManifestId_RevisionNumber",
+ table: "VaultManifests",
+ columns: new[] { "ManifestId", "RevisionNumber" });
+
+ // --- New tables ---
+
+ migrationBuilder.CreateTable(
+ name: "VaultBlobObjects",
+ columns: table => new
+ {
+ Hash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
+ OwnerUserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
+ Category = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
+ EncryptedData = table.Column<byte[]>(type: "bytea", nullable: false),
+ SizeBytes = table.Column<int>(type: "integer", nullable: false),
+ CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ LastReferencedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_VaultBlobObjects", x => new { x.Hash, x.OwnerUserId });
+ table.ForeignKey(
+ name: "FK_VaultBlobObjects_AliasVaultUsers_OwnerUserId",
+ column: x => x.OwnerUserId,
+ principalTable: "AliasVaultUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "VaultDataBuckets",
+ columns: table => new
+ {
+ RevisionId = table.Column<Guid>(type: "uuid", nullable: false),
+ OwnerUserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
+ Category = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
+ EncryptedData = table.Column<string>(type: "text", nullable: false),
+ RevisionNumber = table.Column<long>(type: "bigint", nullable: false),
+ CiphertextHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
+ CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+ UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_VaultDataBuckets", x => x.RevisionId);
+ table.ForeignKey(
+ name: "FK_VaultDataBuckets_AliasVaultUsers_OwnerUserId",
+ column: x => x.OwnerUserId,
+ principalTable: "AliasVaultUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "VaultBlobReferences",
+ columns: table => new
+ {
+ ManifestRevisionId = table.Column<Guid>(type: "uuid", nullable: false),
+ BlobHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_VaultBlobReferences", x => new { x.ManifestRevisionId, x.BlobHash });
+ table.ForeignKey(
+ name: "FK_VaultBlobReferences_VaultManifests_ManifestRevisionId",
+ column: x => x.ManifestRevisionId,
+ principalTable: "VaultManifests",
+ principalColumn: "RevisionId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_VaultBlobObjects_OwnerUserId_Category",
+ table: "VaultBlobObjects",
+ columns: new[] { "OwnerUserId", "Category" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_VaultDataBuckets_OwnerUserId_Category_RevisionNumber",
+ table: "VaultDataBuckets",
+ columns: new[] { "OwnerUserId", "Category", "RevisionNumber" },
+ unique: true);
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ // Drop the new tables (VaultBlobReferences first — it FKs into VaultManifests).
+ migrationBuilder.DropTable(name: "VaultBlobReferences");
+ migrationBuilder.DropTable(name: "VaultBlobObjects");
+ migrationBuilder.DropTable(name: "VaultDataBuckets");
+
+ // Reverse VaultManifests -> Vaults, in place.
+ migrationBuilder.DropIndex(name: "IX_VaultManifests_ManifestId_RevisionNumber", table: "VaultManifests");
+ migrationBuilder.DropColumn(name: "Category", table: "VaultManifests");
+ migrationBuilder.DropColumn(name: "ManifestId", table: "VaultManifests");
+ migrationBuilder.RenameIndex(name: "IX_VaultManifests_OwnerUserId", table: "VaultManifests", newName: "IX_Vaults_UserId");
+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"" TO ""FK_Vaults_AliasVaultUsers_UserId"";");
+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_VaultManifests"" TO ""PK_Vaults"";");
+ migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultManifests", newName: "UserId");
+ migrationBuilder.RenameColumn(name: "RevisionId", table: "VaultManifests", newName: "Id");
+ migrationBuilder.RenameTable(name: "VaultManifests", newName: "Vaults");
+
+ // Drop the storage-format columns added above.
+ migrationBuilder.DropColumn(name: "StorageFormat", table: "Vaults");
+ migrationBuilder.DropColumn(name: "ManifestCiphertextHash", table: "Vaults");
+ migrationBuilder.DropColumn(name: "ManifestBlob", table: "Vaults");
+ }
+ }
+}