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,
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -9,7 +9,7 @@ pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub r#type: i32,
|
||||
pub account_type: i32,
|
||||
pub uid: i64,
|
||||
pub is_deleted: bool,
|
||||
pub created_at: DateTime,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
@@ -7,3 +7,4 @@ pub mod book;
|
||||
pub mod category;
|
||||
pub mod tag;
|
||||
pub mod transaction;
|
||||
pub mod transaction_tag_rel;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
pub use super::account::Entity as Account;
|
||||
pub use super::book::Entity as Book;
|
||||
pub use super::category::Entity as Category;
|
||||
pub use super::tag::Entity as Tag;
|
||||
pub use super::transaction::Entity as Transaction;
|
||||
pub use super::transaction_tag_rel::Entity as TransactionTagRel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.11
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -9,7 +9,7 @@ pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i64,
|
||||
pub uid: i64,
|
||||
pub r#type: i32,
|
||||
pub transaction_type: i32,
|
||||
pub book_id: i64,
|
||||
pub category_id: i64,
|
||||
pub description: String,
|
||||
|
||||
22
src/model/db/transaction_tag_rel.rs
Normal file
22
src/model/db/transaction_tag_rel.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.16
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "transaction_tag_rel")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i64,
|
||||
pub uid: i64,
|
||||
pub transaction_id: i64,
|
||||
pub tag_id: i64,
|
||||
pub is_deleted: bool,
|
||||
pub created_at: DateTime,
|
||||
pub updated_at: DateTime,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user