be able to update data individually; Fixes #952
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m9s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2025-04-30 13:38:45 +02:00
parent c8d5c633d7
commit d2914f9287
6 changed files with 392 additions and 11 deletions

View File

@ -7,7 +7,7 @@ use super::user::User;
#[derive(FromRow, Serialize, Clone)]
pub struct Family {
id: i64,
pub(crate) id: i64,
}
#[derive(Serialize, Clone)]
@ -91,4 +91,18 @@ GROUP BY family.id;"
.await
.unwrap()
}
pub async fn clean_families_without_members(db: &SqlitePool) {
sqlx::query(
"DELETE FROM family
WHERE id NOT IN (
SELECT DISTINCT family_id
FROM user
WHERE family_id IS NOT NULL
);",
)
.execute(db)
.await
.unwrap();
}
}