diff --git a/src/db.rs b/src/db.rs index a87fbc8d..5ab8bed7 100644 --- a/src/db.rs +++ b/src/db.rs @@ -341,8 +341,22 @@ fn fix_entities() -> AppResult<()> { use super::_entities::{module}::{{ActiveModel, Entity}}; pub type {module_pascal} = Entity; +#[async_trait::async_trait] impl ActiveModelBehavior for ActiveModel {{ // extend activemodel below (keep comment for generators) + + async fn before_save(self, _db: &C, insert: bool) -> std::result::Result + where + C: ConnectionTrait, + {{ + if !insert && self.updated_at.is_unchanged() {{ + let mut this = self; + this.updated_at = sea_orm::ActiveValue::Set(chrono::Utc::now().into()); + Ok(this) + }} else {{ + Ok(self) + }} + }} }} " ),