collie_auth/repository/
database.rs

1use sea_query::{ColumnDef, Iden, Table, TableStatement};
2
3#[derive(Iden)]
4pub enum Keys {
5    Table,
6    Id,
7    Access,
8    Secret,
9    Description,
10    ExpiredAt,
11}
12
13pub fn keys_table() -> Vec<TableStatement> {
14    let create = Table::create()
15        .table(Keys::Table)
16        .if_not_exists()
17        .col(
18            ColumnDef::new(Keys::Id)
19                .integer()
20                .not_null()
21                .auto_increment()
22                .primary_key(),
23        )
24        .col(ColumnDef::new(Keys::Access).text().not_null().unique_key())
25        .col(ColumnDef::new(Keys::Secret).text().not_null())
26        .col(ColumnDef::new(Keys::Description).text())
27        .col(ColumnDef::new(Keys::ExpiredAt).date_time())
28        .to_owned();
29
30    vec![TableStatement::Create(create)]
31}