1
0
mirror of https://github.com/bitwarden/server synced 2025-12-28 14:13:48 +00:00

clean up cipher archive

This commit is contained in:
jaasen-livefront
2025-11-13 18:45:21 -08:00
parent 89a0eb2068
commit 690822d13f
3 changed files with 13 additions and 5 deletions

View File

@@ -163,7 +163,6 @@ public class DatabaseContext : DbContext
}
eCipher.ToTable(nameof(Cipher));
eCipherArchive.ToTable(nameof(CipherArchive));
eCollection.ToTable(nameof(Collection));
eCollectionCipher.ToTable(nameof(CollectionCipher));
eEmergencyAccess.ToTable(nameof(EmergencyAccess));

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Bit.Infrastructure.EntityFramework.Vault.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Vault.Configurations;
@@ -17,7 +18,12 @@ public class CipherArchiveConfiguration : IEntityTypeConfiguration<CipherArchive
.HasForeignKey(ca => ca.CipherId)
.OnDelete(DeleteBehavior.Cascade);
// If you want explicit mapping:
builder
.HasOne(ca => ca.User)
.WithMany()
.HasForeignKey(ca => ca.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder.Property(ca => ca.ArchivedDate).IsRequired();
}
}

View File

@@ -1,6 +1,8 @@
#nullable disable
using Bit.Infrastructure.EntityFramework.Vault.Models;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Vault.Models;
public class CipherArchive
{
@@ -8,6 +10,7 @@ public class CipherArchive
public Guid UserId { get; set; }
public DateTime ArchivedDate { get; set; }
// Optional navigation props you can drop these if you don't want them.
// Navigation props
public Cipher Cipher { get; set; }
public User User { get; set; } // optional, matches FK
}