-
-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: DB migration error (revision 29) #378
Comments
Temporary hacky workaround with sonnet diff --git a/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs b/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs
index 5a22cd6..d08f6de 100644
--- a/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs
+++ b/crates/core/database/src/models/admin_migrations/ops/mongodb/scripts.rs
@@ -1148,7 +1148,7 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
channel_id: String,
}
- let invites = db
+ let webhooks = db
.db()
.collection::<WebhookShell>("channel_webhooks")
.find(doc! {}, None)
@@ -1158,22 +1158,38 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
.collect::<Vec<WebhookShell>>()
.await;
- for invite in invites {
- let channel = db.fetch_channel(&invite.channel_id).await.expect("channel");
+ for webhook in webhooks {
+ let channel = match db.fetch_channel(&webhook.channel_id).await {
+ Ok(channel) => channel,
+ Err(_) => {
+ info!("Skipping webhook {} - channel {} not found", webhook._id, webhook.channel_id);
+ continue;
+ }
+ };
+
let creator_id = match channel {
Channel::Group { owner, .. } => owner,
Channel::TextChannel { server, .. } | Channel::VoiceChannel { server, .. } => {
- let server = db.fetch_server(&server).await.expect("server");
+ let server = match db.fetch_server(&server).await {
+ Ok(server) => server,
+ Err(_) => {
+ info!("Skipping webhook {} - server not found", webhook._id);
+ continue;
+ }
+ };
server.owner
}
- _ => unreachable!("not server or group channel!"),
+ _ => {
+ info!("Skipping webhook {} - invalid channel type", webhook._id);
+ continue;
+ }
};
db.db()
.collection::<Document>("channel_webhooks")
.update_one(
doc! {
- "_id": invite._id,
+ "_id": webhook._id,
},
doc! {
"$set" : {
|
Definitely won't be another channel type but I've updated the migration to support missing channels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
Hi, i'd like to report that my revolt DB crashes the program;
Is there any way to fix this? It happens with every db I tried
The text was updated successfully, but these errors were encountered: