events: Add updated_at field

This commit is contained in:
Lennart
2024-07-27 14:38:39 +02:00
parent 9978542c69
commit 21fe841ef1
2 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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