Skip to content

Commit

Permalink
Add tracing and update sql migration
Browse files Browse the repository at this point in the history
  • Loading branch information
weigo0510 committed Apr 9, 2024
1 parent 392cf58 commit 5889027
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 1 deletion.
157 changes: 157 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ sqlx = { version = "0.7.4", features = [
"migrate",
"postgres",
] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use routers::create_router;
use tracing_subscriber::fmt::format::FmtSpan;

use crate::repositories::store::Store;

Expand All @@ -9,7 +10,16 @@ mod routers;

#[tokio::main]
async fn main() {
let store = Store::new("postgres://postgres:pass1234@localhost:5432/webdev");
let store = Store::new("postgres://postgres:pass1234@localhost:5432/rustwebdev").await;

sqlx::migrate!()
.run(&store.clone().connection)
.await
.expect("Cannot run migrate");

tracing_subscriber::fmt()
.with_span_events(FmtSpan::CLOSE)
.init();

let app = create_router();
println!("Server starting...");
Expand Down

0 comments on commit 5889027

Please sign in to comment.