added auto migrations and made cargo rebuild if migrations changed
This commit is contained in:
3
build.rs
Normal file
3
build.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-changed=migrations");
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user