Skip to content

Commit

Permalink
Fixed FK violation error when completely removing a page. Closes #308.
Browse files Browse the repository at this point in the history
  • Loading branch information
impworks committed Dec 7, 2024
1 parent 187c5c6 commit 1dac3c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Bonsai/Areas/Admin/Logic/PagesManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,16 @@ public async Task RemoveCompletelyAsync(Guid id, ClaimsPrincipal principal)

// page-related stuff
await _db.PageDrafts.RemoveWhereAsync(x => x.PageId == id);
await _db.PageAliases.RemoveWhereAsync(x => x.Page.Id == id);
await _db.PageAliases.RemoveWhereAsync(x => x.PageId == id);
await _db.PageReferences.RemoveWhereAsync(x => x.SourceId == id || x.DestinationId == id);
await _db.LivingBeingOverviews.RemoveWhereAsync(x => x.PageId == id);

// users
await foreach (var user in _db.Users.WhereAsync(x => x.PageId == id))
user.PageId = null;

// trees
await _db.TreeLayouts.RemoveWhereAsync(x => x.PageId == id);

// page itself
_db.Pages.Remove(page);
Expand Down

0 comments on commit 1dac3c2

Please sign in to comment.