This commit is contained in:
2024-05-28 15:48:55 +01:00
parent 89fccc8d85
commit 660b7b8676
7 changed files with 63 additions and 80 deletions
@@ -6,54 +6,40 @@ 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(Transaction::Table)
.if_not_exists()
.col(
ColumnDef::new(Transaction::Id)
.string()
.not_null()
.primary_key(),
)
.col(
ColumnDef::new(Transaction::TransactionType)
.string()
.not_null(),
)
.col(
ColumnDef::new(Transaction::TotalAmount)
.decimal()
.not_null(),
)
.col(
ColumnDef::new(Transaction::Timestamp)
.timestamp()
.not_null(),
)
.col(
ColumnDef::new(Transaction::Title)
.string()
.not_null(),
)
.col(
ColumnDef::new(Transaction::Emoji)
.string(),
)
.col(
ColumnDef::new(Transaction::Notes)
.string(),
)
.col(
ColumnDef::new(Transaction::Receipt)
.string(),
)
.col(
ColumnDef::new(Transaction::Description)
.string(),
)
.to_owned()
).await?;
manager
.create_table(
Table::create()
.table(Transaction::Table)
.if_not_exists()
.col(
ColumnDef::new(Transaction::Id)
.string()
.not_null()
.primary_key(),
)
.col(
ColumnDef::new(Transaction::TransactionType)
.string()
.not_null(),
)
.col(
ColumnDef::new(Transaction::TotalAmount)
.decimal()
.not_null(),
)
.col(
ColumnDef::new(Transaction::Timestamp)
.timestamp()
.not_null(),
)
.col(ColumnDef::new(Transaction::Title).string().not_null())
.col(ColumnDef::new(Transaction::Emoji).string())
.col(ColumnDef::new(Transaction::Notes).string())
.col(ColumnDef::new(Transaction::Receipt).string())
.col(ColumnDef::new(Transaction::Description).string())
.to_owned(),
)
.await?;
manager
.create_table(
@@ -73,7 +59,8 @@ impl MigrationTrait for Migration {
)
.col(ColumnDef::new(Expenditure::Amount).decimal().not_null())
.to_owned(),
).await?;
)
.await?;
Ok(())
}