forked from rust-lang/crates.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_config.rs
More file actions
37 lines (34 loc) · 1.17 KB
/
Copy pathgithub_config.rs
File metadata and controls
37 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::schema::trustpub_configs_github;
use chrono::{DateTime, Utc};
use diesel::prelude::*;
use diesel_async::{AsyncPgConnection, RunQueryDsl};
#[derive(Debug, Identifiable, Queryable, Selectable)]
#[diesel(table_name = trustpub_configs_github, check_for_backend(diesel::pg::Pg))]
pub struct GitHubConfig {
pub id: i32,
pub created_at: DateTime<Utc>,
pub crate_id: i32,
pub repository_owner: String,
pub repository_owner_id: i32,
pub repository_name: String,
pub workflow_filename: String,
pub environment: Option<String>,
}
#[derive(Debug, Insertable)]
#[diesel(table_name = trustpub_configs_github, check_for_backend(diesel::pg::Pg))]
pub struct NewGitHubConfig<'a> {
pub crate_id: i32,
pub repository_owner: &'a str,
pub repository_owner_id: i32,
pub repository_name: &'a str,
pub workflow_filename: &'a str,
pub environment: Option<&'a str>,
}
impl NewGitHubConfig<'_> {
pub async fn insert(&self, conn: &mut AsyncPgConnection) -> QueryResult<GitHubConfig> {
self.insert_into(trustpub_configs_github::table)
.returning(GitHubConfig::as_returning())
.get_result(conn)
.await
}
}