Move to FKs

This commit is contained in:
claude Bot committed 2026-10-18 20:06:55 +01:00
1 parent 96bfef4575
commit a9cc0b8f0a
32 files changed
+875 -305

No files matched your search

+31
View File
@@ -109,3 +109,34 @@ macro_rules! path {
}
}};
}
macro_rules! update_image_field {
($pool:expr, $error:ident, $reminder:ident, $field:ident, $id:ident) => {
if let Some(value) = &$reminder.$field {
match crate::image_upload::ImageReference::from_url($pool, value.as_deref()).await {
Ok(image) => {
if let Err(e) = sqlx::query(concat!(
"UPDATE reminders SET `",
stringify!($field),
"` = ?, `",
stringify!($id),
"` = ? WHERE uid = ?"
))
.bind(image.url)
.bind(image.id)
.bind(&$reminder.uid)
.execute($pool)
.await
{
warn!("Could not update image reference: {:?}", e);
$error.push(format!("Error setting field {}", stringify!($field)));
}
}
Err(e) => {
warn!("Could not resolve image upload: {:?}", e);
$error.push(format!("Error setting field {}", stringify!($field)));
}
}
}
};
}