feat: add transaction tag rel model
This commit is contained in:
@@ -5,6 +5,7 @@ mod m20250525_000002_create_ledger_table_book;
|
||||
mod m20250525_000003_create_ledger_table_tag;
|
||||
mod m20250525_000004_create_ledger_table_account;
|
||||
mod m20250525_000005_create_ledger_table_transaction;
|
||||
mod m20250921_000001_create_ledger_table_transaction_tag_rel;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -17,6 +18,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20250525_000003_create_ledger_table_tag::Migration),
|
||||
Box::new(m20250525_000004_create_ledger_table_account::Migration),
|
||||
Box::new(m20250525_000005_create_ledger_table_transaction::Migration),
|
||||
Box::new(m20250921_000001_create_ledger_table_transaction_tag_rel::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
use crate::sea_query;
|
||||
use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager};
|
||||
use crate::{async_trait, ColumnDef, DbErr, Expr, Iden, Table};
|
||||
|
||||
pub struct Migration;
|
||||
|
||||
impl MigrationName for crate::m20250921_000001_create_ledger_table_transaction_tag_rel::Migration {
|
||||
fn name(&self) -> &str {
|
||||
"m20250921_000001_create_ledger_table_transaction_tag_rel" // Make sure this matches with the file name
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for crate::m20250921_000001_create_ledger_table_transaction_tag_rel::Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::Table)
|
||||
.col(
|
||||
ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::Id)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::Uid).big_integer().not_null())
|
||||
.col(ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::TransactionId).big_integer().not_null())
|
||||
.col(ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::TagId).big_integer().not_null())
|
||||
.col(
|
||||
ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::IsDeleted)
|
||||
.boolean()
|
||||
.default(false)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::CreatedAt)
|
||||
.date_time()
|
||||
.default(Expr::current_timestamp())
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::UpdatedAt)
|
||||
.date_time()
|
||||
.default(Expr::current_timestamp())
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
// Define how to rollback this migration: Drop the Bakery table.
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(crate::m20250921_000001_create_ledger_table_transaction_tag_rel::TransactionTagRel::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum TransactionTagRel {
|
||||
Table,
|
||||
Id,
|
||||
Uid,
|
||||
TransactionId,
|
||||
TagId,
|
||||
IsDeleted,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
Reference in New Issue
Block a user