refactor: enforce unique constraints on account and account_category names; update foreign key actions

This commit is contained in:
GW_MC
2026-05-27 11:19:02 +00:00
parent 1b1f9777ec
commit 517fb37818
3 changed files with 8 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
#[sea_orm(unique)]
pub name: String,
pub account_category_id: i64,
pub created_at: String,
@@ -21,7 +22,7 @@ pub enum Relation {
belongs_to = "super::account_category::Entity",
from = "Column::AccountCategoryId",
to = "super::account_category::Column::Id",
on_update = "NoAction",
on_update = "Restrict",
on_delete = "NoAction"
)]
AccountCategory,

View File

@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
#[sea_orm(unique)]
pub name: String,
pub account_type: String,
pub created_at: String,