(toggl-portal): Cache clients in database
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
pub use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20231101_172500_create_time_entry_table;
|
||||
mod m20231106_134950_create_clients;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(
|
||||
m20231101_172500_create_time_entry_table::Migration,
|
||||
)]
|
||||
vec![
|
||||
Box::new(m20231101_172500_create_time_entry_table::Migration),
|
||||
Box::new(m20231106_134950_create_clients::Migration),
|
||||
]
|
||||
}
|
||||
|
||||
fn migration_table_name() -> DynIden {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Client::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Client::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Client::Name).string().not_null())
|
||||
.col(ColumnDef::new(Client::Archived).boolean().not_null())
|
||||
.col(ColumnDef::new(Client::WorkspaceId).integer().not_null())
|
||||
.col(ColumnDef::new(Client::At).timestamp_with_time_zone().not_null())
|
||||
.col(ColumnDef::new(Client::ServerDeletedAt).timestamp_with_time_zone())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Client::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Client {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
Archived,
|
||||
WorkspaceId,
|
||||
At,
|
||||
ServerDeletedAt
|
||||
}
|
||||
Reference in New Issue
Block a user