added subscription model
This commit is contained in:
parent
46dd07f3e4
commit
0eb0e7b295
|
@ -3,3 +3,4 @@
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
*.iml
|
*.iml
|
||||||
|
local.db
|
||||||
|
|
|
@ -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"
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE subscriptions
|
|
@ -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
|
||||||
|
)
|
|
@ -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
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
table! {
|
||||||
|
subscriptions (id) {
|
||||||
|
id -> Integer,
|
||||||
|
callback -> Text,
|
||||||
|
topic -> Text,
|
||||||
|
sec -> Text,
|
||||||
|
created_at -> Integer,
|
||||||
|
expires_at -> Integer,
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue