Update January definitions; add servers collection
This commit is contained in:
@@ -25,6 +25,10 @@ pub async fn create_database() {
|
||||
.await
|
||||
.expect("Failed to create messages collection.");
|
||||
|
||||
db.create_collection("servers", None)
|
||||
.await
|
||||
.expect("Failed to create servers collection.");
|
||||
|
||||
db.create_collection("migrations", None)
|
||||
.await
|
||||
.expect("Failed to create migrations collection.");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::database::get_collection;
|
||||
use crate::database::{get_collection, get_db};
|
||||
|
||||
use log::info;
|
||||
use mongodb::bson::{doc, from_document};
|
||||
@@ -10,7 +10,7 @@ struct MigrationInfo {
|
||||
revision: i32,
|
||||
}
|
||||
|
||||
pub const LATEST_REVISION: i32 = 2;
|
||||
pub const LATEST_REVISION: i32 = 3;
|
||||
|
||||
pub async fn migrate_database() {
|
||||
let migrations = get_collection("migrations");
|
||||
@@ -78,6 +78,15 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
||||
.expect("Failed to update attachments.");
|
||||
}
|
||||
|
||||
if revision <= 2 {
|
||||
info!("Running migration [revision 2 / 2021-05-08]: Add servers collection.");
|
||||
|
||||
get_db()
|
||||
.create_collection("servers", None)
|
||||
.await
|
||||
.expect("Failed to create servers collection.");
|
||||
}
|
||||
|
||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||
LATEST_REVISION
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user