Update January definitions; add servers collection
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export version=0.4.1-alpha.8
|
export version=0.4.1-alpha.9
|
||||||
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
||||||
|
|||||||
@@ -18,12 +18,21 @@ pub struct Media {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Metadata {
|
pub struct Metadata {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
url: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
image: Option<Media>,
|
image: Option<Media>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
site_name: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
icon_url: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
color: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mod guild;
|
mod server;
|
||||||
mod autumn;
|
mod autumn;
|
||||||
mod january;
|
mod january;
|
||||||
mod channel;
|
mod channel;
|
||||||
@@ -8,6 +8,6 @@ mod user;
|
|||||||
pub use january::*;
|
pub use january::*;
|
||||||
pub use autumn::*;
|
pub use autumn::*;
|
||||||
pub use channel::*;
|
pub use channel::*;
|
||||||
pub use guild::*;
|
pub use server::*;
|
||||||
pub use message::*;
|
pub use message::*;
|
||||||
pub use user::*;
|
pub use user::*;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/*#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct MemberCompositeKey {
|
pub struct MemberCompositeKey {
|
||||||
pub guild: String,
|
pub guild: String,
|
||||||
pub user: String,
|
pub user: String,
|
||||||
@@ -27,12 +27,11 @@ pub struct Ban {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Guild {
|
pub struct Server {
|
||||||
#[serde(rename = "_id")]
|
#[serde(rename = "_id")]
|
||||||
pub id: String,
|
pub id: String,
|
||||||
// pub nonce: String, used internally
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub name: String,
|
pub nonce: Option<String>,
|
||||||
pub description: String,
|
|
||||||
pub owner: String,
|
pub owner: String,
|
||||||
|
|
||||||
pub channels: Vec<String>,
|
pub channels: Vec<String>,
|
||||||
@@ -40,4 +39,4 @@ pub struct Guild {
|
|||||||
pub bans: Vec<Ban>,
|
pub bans: Vec<Ban>,
|
||||||
|
|
||||||
pub default_permissions: u32,
|
pub default_permissions: u32,
|
||||||
}*/
|
}
|
||||||
@@ -25,6 +25,10 @@ pub async fn create_database() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create messages collection.");
|
.expect("Failed to create messages collection.");
|
||||||
|
|
||||||
|
db.create_collection("servers", None)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create servers collection.");
|
||||||
|
|
||||||
db.create_collection("migrations", None)
|
db.create_collection("migrations", None)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create migrations collection.");
|
.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 log::info;
|
||||||
use mongodb::bson::{doc, from_document};
|
use mongodb::bson::{doc, from_document};
|
||||||
@@ -10,7 +10,7 @@ struct MigrationInfo {
|
|||||||
revision: i32,
|
revision: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LATEST_REVISION: i32 = 2;
|
pub const LATEST_REVISION: i32 = 3;
|
||||||
|
|
||||||
pub async fn migrate_database() {
|
pub async fn migrate_database() {
|
||||||
let migrations = get_collection("migrations");
|
let migrations = get_collection("migrations");
|
||||||
@@ -78,6 +78,15 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
|||||||
.expect("Failed to update attachments.");
|
.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.
|
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||||
LATEST_REVISION
|
LATEST_REVISION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
pub const VERSION: &str = "0.4.1-alpha.7-patch.2";
|
pub const VERSION: &str = "0.4.1-alpha.9";
|
||||||
|
|||||||
Reference in New Issue
Block a user