Skip to content

Commit

Permalink
Update useremailclaims setnull to be compatible with PostgreSQL (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanedirt committed Dec 25, 2024
1 parent f0e0e9c commit fc85f34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Databases/AliasServerDb/AliasServerDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
// Note: when a user is deleted the email claims user FK's should be set to NULL
// so the claims themselves are preserved to prevent re-use of the email address.
modelBuilder.Entity<UserEmailClaim>()
.HasOne(l => l.User)
.WithMany(c => c.EmailClaims)
.HasForeignKey(l => l.UserId)
.OnDelete(DeleteBehavior.ClientSetNull);
.HasOne(e => e.User)
.WithMany(u => u.EmailClaims)
.HasForeignKey(e => e.UserId)
.OnDelete(DeleteBehavior.SetNull);

// Configure Email - UserEncryptionKey relationship
modelBuilder.Entity<Email>()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
name: "FK_UserEmailClaims_AliasVaultUsers_UserId",
column: x => x.UserId,
principalTable: "AliasVaultUsers",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});

migrationBuilder.CreateTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany("EmailClaims")
.HasForeignKey("UserId");
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);

b.Navigation("User");
});
Expand Down

0 comments on commit fc85f34

Please sign in to comment.