Demo user
This commit is contained in:
parent
e9b215c686
commit
d92a1cd617
1 changed files with 9 additions and 0 deletions
|
@ -2,6 +2,8 @@ use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use log::error;
|
||||||
|
use log::info;
|
||||||
use sqlx::Pool;
|
use sqlx::Pool;
|
||||||
use sqlx::Sqlite;
|
use sqlx::Sqlite;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
@ -30,6 +32,7 @@ impl ServerState {
|
||||||
// This is almost certainly bad practice for more reasons than I can count
|
// This is almost certainly bad practice for more reasons than I can count
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
|
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
|
||||||
|
info!("Using db_url: {}", &db_url);
|
||||||
|
|
||||||
let pool = sqlite::SqlitePoolOptions::new()
|
let pool = sqlite::SqlitePoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
|
@ -39,6 +42,12 @@ impl ServerState {
|
||||||
|
|
||||||
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
|
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)]
|
#[cfg(debug_assertions)]
|
||||||
debug_setup(&pool).await.unwrap();
|
debug_setup(&pool).await.unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue