diff --git a/crates/store/migrations/20240621161002_init.sql b/crates/store/migrations/20240621161002_init.sql index c13147c..ba5baa7 100644 --- a/crates/store/migrations/20240621161002_init.sql +++ b/crates/store/migrations/20240621161002_init.sql @@ -15,6 +15,7 @@ CREATE TABLE events ( cid TEXT NOT NULL, uid TEXT NOT NULL, ics TEXT NOT NULL, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, deleted_at DATETIME, PRIMARY KEY (principal, cid, uid), FOREIGN KEY (principal, cid) REFERENCES calendars(principal, id) diff --git a/crates/store/src/sqlite_store.rs b/crates/store/src/sqlite_store.rs index 7a4182b..0445494 100644 --- a/crates/store/src/sqlite_store.rs +++ b/crates/store/src/sqlite_store.rs @@ -130,7 +130,6 @@ impl CalendarStore for SqliteCalendarStore { Ok(()) } - // Does not actually delete the calendar but just disables it async fn restore_calendar(&mut self, principal: &str, id: &str) -> Result<(), Error> { sqlx::query!( r"UPDATE calendars SET deleted_at = NULL WHERE (principal, id) = (?, ?)", @@ -200,7 +199,7 @@ impl CalendarStore for SqliteCalendarStore { match use_trashbin { true => { sqlx::query!( - "UPDATE events SET deleted_at = datetime() WHERE (principal, cid, uid) = (?, ?, ?)", + "UPDATE events SET deleted_at = datetime(), updated_at = datetime() WHERE (principal, cid, uid) = (?, ?, ?)", principal, cid, uid @@ -219,7 +218,7 @@ impl CalendarStore for SqliteCalendarStore { async fn restore_event(&mut self, principal: &str, cid: &str, uid: &str) -> Result<(), Error> { sqlx::query!( - r#"UPDATE events SET deleted_at = NULL WHERE (principal, cid, uid) = (?, ?, ?)"#, + r#"UPDATE events SET deleted_at = NULL, updated_at = datetime() WHERE (principal, cid, uid) = (?, ?, ?)"#, principal, cid, uid