diff --git a/src/database/migrations/scripts.rs b/src/database/migrations/scripts.rs index 4f570007328613486597208d77be8643692e152d..f952e749e143fd7dd131333e9f9288c1c032427c 100644 --- a/src/database/migrations/scripts.rs +++ b/src/database/migrations/scripts.rs @@ -12,7 +12,7 @@ struct MigrationInfo { revision: i32, } -pub const LATEST_REVISION: i32 = 3; +pub const LATEST_REVISION: i32 = 4; pub async fn migrate_database() { let migrations = get_collection("migrations"); @@ -148,6 +148,23 @@ pub async fn run_migrations(revision: i32) -> i32 { .expect("Failed to create username index."); } + if revision <= 3 { + info!("Running migration [revision 3]: Changed enum tag type to channel_type."); + + get_collection("channels") + .update_many( + doc! { }, + doc! { + "$rename": { + "type": "channel_type" + } + }, + None + ) + .await + .expect("Failed to migrate channel type."); + } + // Reminder to update LATEST_REVISION when adding new migrations. LATEST_REVISION }