1#![allow(clippy::extra_unused_lifetimes)]
9
10use chrono::NaiveDateTime;
13
14use crate::db::schema::*;
15
16#[derive(Queryable, Debug, Clone, AsChangeset, Identifiable)]
17pub(crate) struct Ca {
18 pub id: i32,
19 pub domainname: String,
20}
21
22#[derive(Insertable, Debug)]
23#[table_name = "cas"]
24pub(crate) struct NewCa<'a> {
25 pub domainname: &'a str,
26}
27
28#[derive(Queryable, Debug, Associations, Clone, AsChangeset, Identifiable)]
29#[changeset_options(treat_none_as_null = "true")]
30#[belongs_to(Ca)]
31pub(crate) struct Cacert {
32 pub id: i32,
33 pub active: bool, pub fingerprint: String,
35 pub priv_cert: String, pub backend: Option<String>,
37 pub ca_id: i32,
39}
40
41#[derive(Insertable)]
42#[table_name = "cacerts"]
43pub(crate) struct NewCacert<'a> {
44 pub active: bool,
45 pub fingerprint: &'a str,
46 pub priv_cert: String,
47 pub backend: Option<&'a str>, pub ca_id: i32,
49}
50
51#[derive(Identifiable, Queryable, Debug, Associations, Clone, AsChangeset, PartialEq, Eq, Hash)]
53#[changeset_options(treat_none_as_null = "true")]
54#[belongs_to(Ca)]
55pub struct User {
56 pub id: i32,
57 pub name: Option<String>,
58 pub ca_id: i32,
60}
61
62#[derive(Insertable, Debug)]
63#[table_name = "users"]
64pub(crate) struct NewUser<'a> {
65 pub name: Option<&'a str>,
66 pub ca_id: i32,
67}
68
69#[derive(Identifiable, Queryable, Debug, Associations, Clone, AsChangeset, PartialEq, Eq, Hash)]
71#[changeset_options(treat_none_as_null = "true")]
72#[belongs_to(User)]
73pub struct Cert {
74 pub id: i32,
75 pub fingerprint: String,
76 pub pub_cert: String,
77 pub user_id: Option<i32>,
78 pub delisted: bool,
79 pub inactive: bool,
80}
81
82#[derive(Insertable, Debug)]
83#[table_name = "certs"]
84pub(crate) struct NewCert<'a> {
85 pub fingerprint: &'a str,
86 pub pub_cert: &'a str,
87 pub user_id: Option<i32>,
88 pub delisted: bool,
89 pub inactive: bool,
90}
91
92#[derive(Associations, Identifiable, Queryable, Debug, Clone, AsChangeset)]
94#[table_name = "certs_emails"]
95#[belongs_to(Cert)]
96pub struct CertEmail {
97 pub id: i32,
98 pub addr: String,
99 pub cert_id: i32,
100}
101
102#[derive(Insertable, Debug)]
103#[table_name = "certs_emails"]
104pub(crate) struct NewCertEmail {
105 pub addr: String,
106 pub cert_id: i32,
107}
108
109#[derive(Identifiable, Queryable, Debug, Associations, Clone, AsChangeset)]
111#[belongs_to(Cert)]
112pub struct Revocation {
113 pub id: i32,
114 pub hash: String,
115 pub revocation: String,
116 pub published: bool,
117 pub cert_id: i32,
119}
120
121#[derive(Insertable, Debug)]
122#[table_name = "revocations"]
123pub(crate) struct NewRevocation<'a> {
124 pub hash: &'a str,
125 pub revocation: &'a str,
126 pub published: bool,
127 pub cert_id: i32,
128}
129
130#[derive(Identifiable, Queryable, Clone, AsChangeset, Debug)]
132pub struct Bridge {
133 pub id: i32,
134 pub email: String,
135 pub scope: String,
136 pub cert_id: i32,
137 pub cas_id: i32,
138}
139
140#[derive(Insertable, Debug)]
141#[table_name = "bridges"]
142pub(crate) struct NewBridge<'a> {
143 pub email: &'a str,
144 pub scope: &'a str,
145 pub cert_id: i32,
146 pub cas_id: i32,
147}
148
149#[derive(Identifiable, Queryable, Clone, AsChangeset, Debug)]
151#[table_name = "queue"]
152pub struct Queue {
153 pub id: i32,
154 pub created: NaiveDateTime,
155 pub task: String,
156 pub done: bool,
157}
158
159#[derive(Insertable, Debug)]
160#[table_name = "queue"]
161pub(crate) struct NewQueue<'a> {
162 pub created: NaiveDateTime,
163 pub task: &'a str,
164 pub done: bool,
165}
166
167