implement handlers table
This commit is contained in:
parent
550e80f91c
commit
df2f2dcd46
|
@ -0,0 +1 @@
|
|||
-- This file should undo anything in `up.sql`
|
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE IF NOT EXISTS handlers
|
||||
( id UUID DEFAULT uuid_generate_v4() NOT NULL
|
||||
, user_id UUID NOT NULL
|
||||
, human_name VARCHAR NOT NULL
|
||||
, current_version VARCHAR NOT NULL
|
||||
, async_impl BOOLEAN DEFAULT false
|
||||
, created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
, updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
, PRIMARY KEY (id)
|
||||
, CONSTRAINT fk_user_id
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES users(id)
|
||||
);
|
||||
|
||||
CREATE TRIGGER set_timestamp_handlers
|
||||
BEFORE UPDATE ON handlers
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE trigger_set_timestamp();
|
|
@ -100,10 +100,10 @@ fn gitea_callback(
|
|||
user_id: user.id.clone(),
|
||||
})
|
||||
.get_result(&*conn)
|
||||
.expect("create token information");
|
||||
.map_err(api::Error::Database)?;
|
||||
info!("created new token for {} with id {}", user.id, tok.id);
|
||||
|
||||
let tok = jwt::make(user.id, tok.id).expect("to sign JWT");
|
||||
let tok = jwt::make(user.id, tok.id).map_err(api::Error::InternalServerError)?;
|
||||
|
||||
cookies.add_private(
|
||||
Cookie::build("token", tok.clone())
|
||||
|
|
|
@ -9,6 +9,18 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
handlers (id) {
|
||||
id -> Uuid,
|
||||
user_id -> Uuid,
|
||||
human_name -> Varchar,
|
||||
current_version -> Varchar,
|
||||
async_impl -> Nullable<Bool>,
|
||||
created_at -> Timestamp,
|
||||
updated_at -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
tokens (id) {
|
||||
id -> Uuid,
|
||||
|
@ -32,10 +44,9 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
joinable!(gitea_tokens -> users (user_id));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
gitea_tokens,
|
||||
handlers,
|
||||
tokens,
|
||||
users,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue