mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
server: Embed migrations
This commit is contained in:
parent
f960971fdb
commit
6a40921ac4
3 changed files with 12 additions and 0 deletions
|
|
@ -22,6 +22,9 @@ pub use works::*;
|
|||
|
||||
mod schema;
|
||||
|
||||
// This makes the SQL migration scripts accessible from the code.
|
||||
embed_migrations!();
|
||||
|
||||
/// A pool of connections to the database.
|
||||
pub type DbPool = r2d2::Pool<r2d2::ConnectionManager<PgConnection>>;
|
||||
|
||||
|
|
@ -35,5 +38,9 @@ pub fn connect() -> Result<DbPool> {
|
|||
let manager = r2d2::ConnectionManager::<PgConnection>::new(url);
|
||||
let pool = r2d2::Pool::new(manager)?;
|
||||
|
||||
// Run embedded migrations.
|
||||
let conn = pool.get()?;
|
||||
embedded_migrations::run(&conn)?;
|
||||
|
||||
Ok(pool)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue