Skip to content

Commit

Permalink
fix: detach rather than delete emoji during server deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Aug 20, 2024
1 parent a52d610 commit 12ae781
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/core/database/src/models/servers/ops/mongodb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,21 @@ impl MongoDb {

// Delete all emoji.
self.col::<Document>("emojis")
.delete_many(
.update_many(
doc! {
"parent.id": &server_id
},
doc! {
"$set": {
"parent": {
"type": "Detached"
}
}
},
None,
)
.await
.map_err(|_| create_database_error!("delete_many", "emojis"))?;
.map_err(|_| create_database_error!("update_many", "emojis"))?;

// Delete all channels.
self.col::<Document>("channels")
Expand Down

0 comments on commit 12ae781

Please sign in to comment.