parent
4b1e1f9222
commit
b7a7ae53ab
5 changed files with 348 additions and 247 deletions
555
Cargo.lock
generated
555
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
24
Cargo.toml
24
Cargo.toml
|
@ -23,8 +23,8 @@ hyper = "0.11"
|
|||
lazy_static = "0.2"
|
||||
maplit = "1"
|
||||
percent-encoding = "1.0.0"
|
||||
r2d2 = "0.7"
|
||||
r2d2-diesel = "0.16"
|
||||
r2d2 = "0.8"
|
||||
r2d2-diesel = "0.99"
|
||||
regex = "0.2"
|
||||
serde = "1.0.0"
|
||||
serde_derive = "1.0.0"
|
||||
|
@ -38,17 +38,22 @@ tokio-service = "0.1"
|
|||
|
||||
[dependencies.libsqlite3-sys]
|
||||
features = ["bundled"]
|
||||
version = "*"
|
||||
version = "0.8"
|
||||
|
||||
[dependencies.diesel]
|
||||
default-features = false
|
||||
features = ["sqlite", "chrono"]
|
||||
version = "0.16"
|
||||
version = "0.99"
|
||||
|
||||
[dependencies.diesel_codegen]
|
||||
[dependencies.diesel_migrations]
|
||||
default-features = false
|
||||
features = ["sqlite"]
|
||||
version = "0.16"
|
||||
version = "0.99"
|
||||
|
||||
[dependencies.diesel_infer_schema]
|
||||
default-features = false
|
||||
features = ["sqlite"]
|
||||
version = "0.99"
|
||||
|
||||
[dependencies.num]
|
||||
default-features = false
|
||||
|
@ -68,6 +73,11 @@ walkdir = "1"
|
|||
[build-dependencies.diesel]
|
||||
default-features = false
|
||||
features = ["sqlite", "chrono"]
|
||||
version = "0.16.0"
|
||||
version = "0.99"
|
||||
|
||||
[build-dependencies.diesel_migrations]
|
||||
default-features = false
|
||||
features = ["sqlite"]
|
||||
version = "0.99"
|
||||
|
||||
[workspace]
|
||||
|
|
3
build.rs
3
build.rs
|
@ -1,4 +1,5 @@
|
|||
#[macro_use] extern crate quote;
|
||||
extern crate diesel_migrations;
|
||||
extern crate diesel;
|
||||
extern crate walkdir;
|
||||
|
||||
|
@ -25,7 +26,7 @@ fn main() {
|
|||
.execute(&connection)
|
||||
.expect("Should be able to enable foreign keys");
|
||||
|
||||
diesel::migrations::run_pending_migrations(&connection).unwrap();
|
||||
diesel_migrations::run_pending_migrations(&connection).unwrap();
|
||||
|
||||
let infer_schema_path = Path::new(&out_dir).join("infer_schema.rs");
|
||||
let mut file = File::create(infer_schema_path).expect("Unable to open file for writing");
|
||||
|
|
10
src/db.rs
10
src/db.rs
|
@ -1,7 +1,7 @@
|
|||
use diesel::prelude::*;
|
||||
use diesel::expression::sql_literal::sql;
|
||||
use diesel::types::*;
|
||||
use r2d2::{Config, CustomizeConnection, Pool};
|
||||
use r2d2::{CustomizeConnection, Pool};
|
||||
use r2d2_diesel::{self, ConnectionManager};
|
||||
|
||||
embed_migrations!();
|
||||
|
@ -19,12 +19,10 @@ impl CustomizeConnection<SqliteConnection, r2d2_diesel::Error> for SqliteInitial
|
|||
}
|
||||
|
||||
pub fn create_pool<S: Into<String>>(connection_string: S) -> Result<Pool<ConnectionManager<SqliteConnection>>, Box<::std::error::Error>> {
|
||||
let config = Config::builder()
|
||||
.connection_customizer(Box::new(SqliteInitializer {}))
|
||||
.build();
|
||||
let manager = ConnectionManager::<SqliteConnection>::new(connection_string);
|
||||
|
||||
let pool = Pool::new(config, manager)?;
|
||||
let pool = Pool::builder()
|
||||
.connection_customizer(Box::new(SqliteInitializer {}))
|
||||
.build(manager)?;
|
||||
|
||||
embedded_migrations::run(&*pool.get()?)?;
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
#[macro_use] extern crate bart_derive;
|
||||
#[macro_use] extern crate codegen;
|
||||
#[macro_use] extern crate diesel_codegen;
|
||||
#[macro_use] extern crate diesel_infer_schema;
|
||||
#[macro_use] extern crate diesel_migrations;
|
||||
#[macro_use] extern crate diesel;
|
||||
#[macro_use] extern crate hyper;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
|
Loading…
Reference in a new issue