diff --git a/.gitignore b/.gitignore index 50945e3..feb219c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .idea .vscode *.iml +local.db diff --git a/diesel.toml b/diesel.toml new file mode 100644 index 0000000..92267c8 --- /dev/null +++ b/diesel.toml @@ -0,0 +1,5 @@ +# For documentation on how to configure this file, +# see diesel.rs/guides/configuring-diesel-cli + +[print_schema] +file = "src/schema.rs" diff --git a/migrations/.gitkeep b/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/migrations/2019-04-01-223446_add_subscriptons/down.sql b/migrations/2019-04-01-223446_add_subscriptons/down.sql new file mode 100644 index 0000000..9253f9d --- /dev/null +++ b/migrations/2019-04-01-223446_add_subscriptons/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +DROP TABLE subscriptions diff --git a/migrations/2019-04-01-223446_add_subscriptons/up.sql b/migrations/2019-04-01-223446_add_subscriptons/up.sql new file mode 100644 index 0000000..d1e8c6e --- /dev/null +++ b/migrations/2019-04-01-223446_add_subscriptons/up.sql @@ -0,0 +1,9 @@ +-- Your SQL goes here +CREATE TABLE subscriptions ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + callback VARCHAR NOT NULL, + topic VARCHAR NOT NULL, + sec VARCHAR NOT NULL, + created_at INTEGER NOT NULL, + expires_at INTEGER NOT NULL +) diff --git a/src/models.rs b/src/models.rs new file mode 100644 index 0000000..56af7cb --- /dev/null +++ b/src/models.rs @@ -0,0 +1,21 @@ +use super::schema::posts; + +#[derive(Queryable)] +pub struct Subscription { + pub id: i32, + pub callback: String, + pub topic: String, + pub sec: String, + pub created_at: i32, + pub expires_at: i32 +} + +#[derive(Insertable)] +#[table_name="subscriptions"] +pub struct NewSubscription<'a> { + pub callback: &'a str, + pub topic: &'a str, + pub sec: &'a str, + pub created_at: &'a i32, + pub expires_at: &'a i32 +} diff --git a/src/schema.rs b/src/schema.rs new file mode 100644 index 0000000..d4fb58f --- /dev/null +++ b/src/schema.rs @@ -0,0 +1,10 @@ +table! { + subscriptions (id) { + id -> Integer, + callback -> Text, + topic -> Text, + sec -> Text, + created_at -> Integer, + expires_at -> Integer, + } +}