added auto migrations and made cargo rebuild if migrations changed

This commit is contained in:
Gvidas Juknevičius 2024-03-25 23:35:16 +02:00
parent 779381df2d
commit 7fbfbaa039
2 changed files with 6 additions and 0 deletions

3
build.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rerun-if-changed=migrations");
}

View File

@ -15,6 +15,9 @@ pub struct Database {
impl Database { impl Database {
pub async fn new(config: &Config) -> anyhow::Result<Self> { pub async fn new(config: &Config) -> anyhow::Result<Self> {
sqlx::migrate!("./migrations");
log::info!("Database connecting to {}", config.database.url); log::info!("Database connecting to {}", config.database.url);
let conn = PgPoolOptions::new() let conn = PgPoolOptions::new()
.max_connections(5) .max_connections(5)