From 3eba02283648ab8ceb97e5088c3baf372faa33bc Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Mon, 30 May 2022 00:03:24 -0400 Subject: sql: Embed migrations within binary Also runs on startup to make upgrading easier --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 65a32d4..355cc88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,6 +39,10 @@ async fn main() { let mut conn = PgPoolOptions::new() .max_connections(5) .connect(&std::env::var("DATABASE_URL").unwrap_or("postgres://postgres@localhost/homeworld".to_string())).await.unwrap(); + + sqlx::migrate!("./migrations") + .run(&conn) + .await.unwrap(); let shared_state = Arc::new(State { conn -- cgit v1.2.3