Demo user

This commit is contained in:
Imbus 2023-11-02 11:29:34 +01:00
parent e9b215c686
commit d92a1cd617

View file

@ -2,6 +2,8 @@ use std::collections::BTreeMap;
use std::sync::Arc;
use std::sync::Mutex;
use log::error;
use log::info;
use sqlx::Pool;
use sqlx::Sqlite;
use sqlx::SqlitePool;
@ -30,6 +32,7 @@ impl ServerState {
// This is almost certainly bad practice for more reasons than I can count
dotenvy::dotenv().ok();
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
info!("Using db_url: {}", &db_url);
let pool = sqlite::SqlitePoolOptions::new()
.max_connections(5)
@ -39,6 +42,12 @@ impl ServerState {
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
match crate::db::db_new_user("imbus".to_string(), "kartellen1234".to_string(), &pool).await
{
Some(u) => info!("Created default user {}", u.username),
None => error!("Failed to create default user..."),
}
#[cfg(debug_assertions)]
debug_setup(&pool).await.unwrap();