Initial work re-implementing model for TimeEntries

This commit is contained in:
2023-11-01 17:32:26 +00:00
parent 31b322d643
commit 8f39bf7d23
12 changed files with 194 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
pub use sea_orm_migration::prelude::*;
mod m20231101_172500_create_time_entry_table;
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),
]
}
}
@@ -0,0 +1,47 @@
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(TimeEntry::Table)
.if_not_exists()
.col(
ColumnDef::new(TimeEntry::Id)
.big_integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(TimeEntry::Description).string().not_null())
.col(ColumnDef::new(TimeEntry::ProjectId).big_integer())
.col(ColumnDef::new(TimeEntry::Start).timestamp().not_null())
.col(ColumnDef::new(TimeEntry::Stop).timestamp().not_null())
.col(ColumnDef::new(TimeEntry::RawJson).json_binary().not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(TimeEntry::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
enum TimeEntry {
Table,
Id,
Description,
ProjectId,
Start,
Stop,
RawJson
}
+6
View File
@@ -0,0 +1,6 @@
use sea_orm_migration::prelude::*;
#[async_std::main]
async fn main() {
cli::run_cli(migration::Migrator).await;
}