Skip to content
Snippets Groups Projects
Commit 1d390d48 authored by insert's avatar insert
Browse files

Add a database migration for channel tag enum.

parent 81de29e7
No related merge requests found
Pipeline #493 canceled with stage
......@@ -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
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment