diff --git a/examples/diesel/.env b/examples/diesel/.env deleted file mode 100644 index 5fcb3f1..0000000 --- a/examples/diesel/.env +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=postgres://user:test@localhost:5534/db \ No newline at end of file diff --git a/examples/diesel/Cargo.toml b/examples/diesel/Cargo.toml deleted file mode 100644 index df27c6d..0000000 --- a/examples/diesel/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "itconfig-diesel-example" -version = "0.1.0" -authors = ["Dmitriy Pleshevskiy "] -edition = "2018" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -itconfig = { path = "../../itconfig", default-features = false, features = ["macro"] } -dotenv = "0.15.0" -diesel = { version = "1.4.6", features = ["postgres"] } diff --git a/examples/diesel/diesel.toml b/examples/diesel/diesel.toml deleted file mode 100644 index 56bd2de..0000000 --- a/examples/diesel/diesel.toml +++ /dev/null @@ -1,5 +0,0 @@ -# For documentation on how to configure this file, -# see diesel.rs/guides/configuring-diesel-cli - -[print_schema] -file = "schema.rs" diff --git a/examples/diesel/docker-compose.example.yml b/examples/diesel/docker-compose.example.yml deleted file mode 100644 index c4f7b49..0000000 --- a/examples/diesel/docker-compose.example.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3' - -services: - postgresql: - image: postgres:12-alpine - ports: - - 5534:5432 - environment: - POSTGRES_PASSWORD: test - POSTGRES_USER: user - POSTGRES_DB: db diff --git a/examples/diesel/main.rs b/examples/diesel/main.rs deleted file mode 100644 index b47f460..0000000 --- a/examples/diesel/main.rs +++ /dev/null @@ -1,51 +0,0 @@ -#[macro_use] -extern crate diesel; - -mod schema; - -use diesel::prelude::*; -use dotenv::dotenv; - -itconfig::config! { - DATABASE_URL, -} - -fn main() { - dotenv().expect("dotenv setup to be successful"); - config::init(); - - let connection = establish_connection(); - let posts = get_posts(&connection); - - println!("Displaying {} posts", posts.len()); - for post in posts { - println!(); - println!("{}", post.title); - println!("----------"); - println!("{}", post.body); - } -} - -fn get_posts(connection: &PgConnection) -> Vec { - use crate::schema::posts::dsl::*; - - posts - .filter(published.eq(true)) - .limit(5) - .get_results::(connection) - .expect("Error loading posts") -} - -fn establish_connection() -> PgConnection { - let database_url = config::DATABASE_URL(); - PgConnection::establish(database_url) - .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)) -} - -#[derive(Queryable)] -struct Post { - pub id: i32, - pub title: String, - pub body: String, - pub published: bool, -} diff --git a/examples/diesel/migrations/.gitkeep b/examples/diesel/migrations/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/diesel/migrations/00000000000000_diesel_initial_setup/down.sql b/examples/diesel/migrations/00000000000000_diesel_initial_setup/down.sql deleted file mode 100644 index a9f5260..0000000 --- a/examples/diesel/migrations/00000000000000_diesel_initial_setup/down.sql +++ /dev/null @@ -1,6 +0,0 @@ --- This file was automatically created by Diesel to setup helper functions --- and other internal bookkeeping. This file is safe to edit, any future --- changes will be added to existing projects as new migrations. - -DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); -DROP FUNCTION IF EXISTS diesel_set_updated_at(); diff --git a/examples/diesel/migrations/00000000000000_diesel_initial_setup/up.sql b/examples/diesel/migrations/00000000000000_diesel_initial_setup/up.sql deleted file mode 100644 index d68895b..0000000 --- a/examples/diesel/migrations/00000000000000_diesel_initial_setup/up.sql +++ /dev/null @@ -1,36 +0,0 @@ --- This file was automatically created by Diesel to setup helper functions --- and other internal bookkeeping. This file is safe to edit, any future --- changes will be added to existing projects as new migrations. - - - - --- Sets up a trigger for the given table to automatically set a column called --- `updated_at` whenever the row is modified (unless `updated_at` was included --- in the modified columns) --- --- # Example --- --- ```sql --- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); --- --- SELECT diesel_manage_updated_at('users'); --- ``` -CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$ -BEGIN - EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s - FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); -END; -$$ LANGUAGE plpgsql; - -CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$ -BEGIN - IF ( - NEW IS DISTINCT FROM OLD AND - NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at - ) THEN - NEW.updated_at := current_timestamp; - END IF; - RETURN NEW; -END; -$$ LANGUAGE plpgsql; diff --git a/examples/diesel/migrations/2019-12-28-212542_create-posts/down.sql b/examples/diesel/migrations/2019-12-28-212542_create-posts/down.sql deleted file mode 100644 index fe33dfa..0000000 --- a/examples/diesel/migrations/2019-12-28-212542_create-posts/down.sql +++ /dev/null @@ -1,2 +0,0 @@ --- This file should undo anything in `up.sql` -DROP TABLE posts; \ No newline at end of file diff --git a/examples/diesel/migrations/2019-12-28-212542_create-posts/up.sql b/examples/diesel/migrations/2019-12-28-212542_create-posts/up.sql deleted file mode 100644 index 47c229b..0000000 --- a/examples/diesel/migrations/2019-12-28-212542_create-posts/up.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Your SQL goes here -CREATE TABLE posts ( - id SERIAL PRIMARY KEY, - title VARCHAR NOT NULL, - body TEXT NOT NULL, - published BOOLEAN NOT NULL DEFAULT 'f' -); - -INSERT INTO posts (title, body, published) -VALUES ('First post', 'Interesting body', 't'), - ('Second post', 'Very interesting post', 't'), - ('Draft post', 'This is post will not be shown', 'f'); \ No newline at end of file diff --git a/examples/diesel/schema.rs b/examples/diesel/schema.rs deleted file mode 100644 index 3124ea5..0000000 --- a/examples/diesel/schema.rs +++ /dev/null @@ -1,8 +0,0 @@ -table! { - posts (id) { - id -> Int4, - title -> Varchar, - body -> Text, - published -> Bool, - } -} diff --git a/itconfig/Cargo.toml b/itconfig/Cargo.toml index f52b65b..e5ce921 100644 --- a/itconfig/Cargo.toml +++ b/itconfig/Cargo.toml @@ -61,8 +61,6 @@ tokio = { version = "1.2.0", features = ["macros", "rt-multi-thread"] } bytes = "1.0.1" futures-util = { version = "0.3.13", default-features = false } pretty_env_logger = "0.4.0" -dotenv = "0.15.0" -diesel = { version = "1.4.8", features = ["postgres"] } [badges] maintenance = { status = "passively-maintained" } @@ -71,11 +69,6 @@ maintenance = { status = "passively-maintained" } [package.metadata.docs.rs] all-features = true -[[example]] -name = "diesel" -path = "../examples/diesel/main.rs" -required-features = ["macro"] - [[example]] name = "hyper" path = "../examples/hyper.rs"