feat(core): add database utils
This commit is contained in:
parent
bc3421b150
commit
d8ed9fd25a
3 changed files with 13 additions and 9 deletions
|
@ -4,6 +4,5 @@ version = "0.1.0"
|
|||
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
postgres = "0.19.0"
|
||||
|
|
9
migra-core/src/database.rs
Normal file
9
migra-core/src/database.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use postgres::{Client, NoTls, Error};
|
||||
|
||||
pub fn connect(connection_string: &str) -> Result<Client, Error> {
|
||||
Client::connect(connection_string, NoTls)
|
||||
}
|
||||
|
||||
pub fn apply_sql(client: &mut Client, sql_content: &str) -> Result<(), Error> {
|
||||
client.batch_execute(sql_content)
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
#![deny(clippy::all)]
|
||||
|
||||
pub mod database;
|
||||
|
|
Reference in a new issue