Add a database migration for channel tag enum.
This commit is contained in:
@@ -12,7 +12,7 @@ struct MigrationInfo {
|
|||||||
revision: i32,
|
revision: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LATEST_REVISION: i32 = 3;
|
pub const LATEST_REVISION: i32 = 4;
|
||||||
|
|
||||||
pub async fn migrate_database() {
|
pub async fn migrate_database() {
|
||||||
let migrations = get_collection("migrations");
|
let migrations = get_collection("migrations");
|
||||||
@@ -148,6 +148,23 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
|||||||
.expect("Failed to create username index.");
|
.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.
|
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||||
LATEST_REVISION
|
LATEST_REVISION
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user