Browse Source

use sqlx for migrations

pbs
jake 4 years ago
parent
commit
69374ea424
  1. 7
      src/entity/gateway/postgres/postgres.rs

7
src/entity/gateway/postgres/postgres.rs

@ -31,8 +31,11 @@ pub struct PostgresGateway {
impl PostgresGateway {
pub fn new(host: &str, dbname: &str, username: &str, password: &str) -> PostgresGateway {
// the postgres dep can be removed once refinery supports sqlx
let mut conn = Client::connect(&format!("host='{}' dbname='{}' user='{}' password='{}'", host, dbname, username, password), NoTls).unwrap();
let mut conn = refinery::config::Config::new(refinery::config::ConfigDbType::Postgres)
.set_db_host(&host)
.set_db_user(&username)
.set_db_pass(&password)
.set_db_name(&dbname);
embedded::migrations::runner().run(&mut conn).unwrap();
let pool = async_std::task::block_on(async move {

Loading…
Cancel
Save