diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2024-10-26 20:53:10 +0200 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2024-10-26 20:53:10 +0200 |
| commit | aebd01540cc09724f68366709281d2350f758f8c (patch) | |
| tree | b772bc9c4720c6533f388f8325965b9f6a785467 /src/main.rs | |
| parent | 2a15bc0bf15d845371c00e07d9ab35b96c669e92 (diff) | |
Feat: Add initial tables
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 335649c..d99fbe9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,12 @@ +use std::env; + use axum::extract::DefaultBodyLimit; use axum::http::StatusCode; use axum::response::IntoResponse; use axum::routing::get; use axum::Router; use maud::{html, Markup, DOCTYPE}; +use sqlx::sqlite::SqlitePoolOptions; use tower_http::services::ServeDir; struct AppError(anyhow::Error); @@ -29,6 +32,18 @@ where #[tokio::main] async fn main() { + let pool = SqlitePoolOptions::new() + .connect( + &env::var("DATABASE_URL").expect("Failed to get environment variable DATABASE_URL"), + ) + .await + .expect("Failed to connect to database"); + + sqlx::migrate!() + .run(&pool) + .await + .expect("Failed to run migrations"); + let app = Router::new() .route("/", get(home)) .nest_service("/static", ServeDir::new("src/static")) |
