commit 0af1ef387dbb7fa8c0f492c90e66c1e32d55e11e
parent 03ff5e6ecea1de20054f580535f6d3586d09f79e
Author: Daniel GarcĂa <dani-garcia@users.noreply.github.com>
Date: Tue, 21 Feb 2023 21:27:35 +0100
Merge branch 'BlackDex-issue-3247'
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/db/models/group.rs b/src/db/models/group.rs
@@ -151,6 +151,13 @@ impl Group {
}
}
+ pub async fn delete_all_by_organization(org_uuid: &str, conn: &mut DbConn) -> EmptyResult {
+ for group in Self::find_by_organization(org_uuid, conn).await {
+ group.delete(conn).await?;
+ }
+ Ok(())
+ }
+
pub async fn find_by_organization(organizations_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
db_run! { conn: {
groups::table
diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs
@@ -2,7 +2,7 @@ use num_traits::FromPrimitive;
use serde_json::Value;
use std::cmp::Ordering;
-use super::{CollectionUser, GroupUser, OrgPolicy, OrgPolicyType, TwoFactor, User};
+use super::{CollectionUser, Group, GroupUser, OrgPolicy, OrgPolicyType, TwoFactor, User};
use crate::CONFIG;
db_object! {
@@ -267,6 +267,7 @@ impl Organization {
Collection::delete_all_by_organization(&self.uuid, conn).await?;
UserOrganization::delete_all_by_organization(&self.uuid, conn).await?;
OrgPolicy::delete_all_by_organization(&self.uuid, conn).await?;
+ Group::delete_all_by_organization(&self.uuid, conn).await?;
db_run! { conn: {
diesel::delete(organizations::table.filter(organizations::uuid.eq(self.uuid)))