birdseed 0.2.0

birdseed enables you to seed a libellis database with fake data, clear all tables, or rebuild all tables per the current embedded migrations
Documentation
extern crate r2d2;

use diesel::pg::PgConnection;
use diesel::r2d2::ConnectionManager;

use std::env;

type ManagedPgConn = ConnectionManager<PgConnection>;

/// Pool type is a simple wrapper over r2d2::Pool<ManagedPgConn> -> use it to pass around your
/// pool.
pub type Pool = r2d2::Pool<ManagedPgConn>;

fn init(database_url: &str) -> Pool {
    let manager = ConnectionManager::<PgConnection>::new(database_url);
    r2d2::Pool::new(manager).expect("Failed to create pool.")
}

/// Establishes a connection to the libellis postgres database on your machine, as specified by your
/// DATABASE_URL environment variable. Returns a Pool.
pub fn generate_pool() -> Pool {
    let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");

    init(&database_url)
}