Add a model for external apps
Stores their name, website, and credentials
This commit is contained in:
parent
76ca76f068
commit
4c8a727e9e
2
migrations/postgres/2018-10-19-165407_create_apps/down.sql
Executable file
2
migrations/postgres/2018-10-19-165407_create_apps/down.sql
Executable file
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE apps;
|
10
migrations/postgres/2018-10-19-165407_create_apps/up.sql
Executable file
10
migrations/postgres/2018-10-19-165407_create_apps/up.sql
Executable file
@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE apps (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL DEFAULT '',
|
||||
client_id TEXT NOT NULL,
|
||||
client_secret TEXT NOT NULL,
|
||||
redirect_uri TEXT,
|
||||
website TEXT,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now()
|
||||
);
|
2
migrations/sqlite/2018-10-19-165450_create_apps/down.sql
Executable file
2
migrations/sqlite/2018-10-19-165450_create_apps/down.sql
Executable file
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE apps;
|
10
migrations/sqlite/2018-10-19-165450_create_apps/up.sql
Executable file
10
migrations/sqlite/2018-10-19-165450_create_apps/up.sql
Executable file
@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE apps (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL DEFAULT '',
|
||||
client_id TEXT NOT NULL,
|
||||
client_secret TEXT NOT NULL,
|
||||
redirect_uri TEXT,
|
||||
website TEXT,
|
||||
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
18
plume-models/src/apps.rs
Executable file
18
plume-models/src/apps.rs
Executable file
@ -0,0 +1,18 @@
|
||||
use chrono::NaiveDateTime;
|
||||
|
||||
use schema::apps;
|
||||
|
||||
pub struct App {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub client_id: String,
|
||||
pub client_secret: String,
|
||||
pub redirect_uri: Option<String>,
|
||||
pub website: Option<String>,
|
||||
pub creation_date: NaiveDateTime,
|
||||
}
|
||||
|
||||
impl App {
|
||||
get!(apps, App);
|
||||
insert!(apps, NewApp);
|
||||
}
|
@ -214,6 +214,7 @@ pub fn ap_url(url: String) -> String {
|
||||
}
|
||||
|
||||
pub mod admin;
|
||||
pub mod apps;
|
||||
pub mod blog_authors;
|
||||
pub mod blogs;
|
||||
pub mod comments;
|
||||
|
@ -1,3 +1,15 @@
|
||||
table! {
|
||||
apps (id) {
|
||||
id -> Int4,
|
||||
name -> Text,
|
||||
client_id -> Text,
|
||||
client_secret -> Text,
|
||||
redirect_uri -> Nullable<Text>,
|
||||
website -> Nullable<Text>,
|
||||
creation_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
blog_authors (id) {
|
||||
id -> Int4,
|
||||
@ -192,6 +204,7 @@ joinable!(tags -> posts (post_id));
|
||||
joinable!(users -> instances (instance_id));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
apps,
|
||||
blog_authors,
|
||||
blogs,
|
||||
comments,
|
||||
|
Loading…
Reference in New Issue
Block a user