From ecd74b794f1ffb7da05bce0046fb8d096b039409 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Mon, 3 Feb 2025 08:37:46 +0100 Subject: [PATCH] fix: non LDAP user group can't be updated after update --- backend/internal/service/user_group_service.go | 1 - ...down.sql => 20250120102531_fix_empty_ldap_id_string.down.sql} | 0 ...ing.up.sql => 20250120102531_fix_empty_ldap_id_string.up.sql} | 0 .../20250203082527_fix_empty_user_group_ldap_id_string.down.sql | 1 + .../20250203082527_fix_empty_user_group_ldap_id_string.up.sql | 1 + ...down.sql => 20250120102531_fix_empty_ldap_id_string.down.sql} | 0 ...ing.up.sql => 20250120102531_fix_empty_ldap_id_string.up.sql} | 0 .../20250203082527_fix_empty_user_group_ldap_id_string.down.sql | 1 + .../20250203082527_fix_empty_user_group_ldap_id_string.up.sql | 1 + 9 files changed, 4 insertions(+), 1 deletion(-) rename backend/resources/migrations/postgres/{20250120102531_fix_empy_ldap_id_string.down.sql => 20250120102531_fix_empty_ldap_id_string.down.sql} (100%) rename backend/resources/migrations/postgres/{20250120102531_fix_empy_ldap_id_string.up.sql => 20250120102531_fix_empty_ldap_id_string.up.sql} (100%) create mode 100644 backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.down.sql create mode 100644 backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.up.sql rename backend/resources/migrations/sqlite/{20250120102531_fix_empy_ldap_id_string.down.sql => 20250120102531_fix_empty_ldap_id_string.down.sql} (100%) rename backend/resources/migrations/sqlite/{20250120102531_fix_empy_ldap_id_string.up.sql => 20250120102531_fix_empty_ldap_id_string.up.sql} (100%) create mode 100644 backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql create mode 100644 backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql diff --git a/backend/internal/service/user_group_service.go b/backend/internal/service/user_group_service.go index 9b68af7..fa146ee 100644 --- a/backend/internal/service/user_group_service.go +++ b/backend/internal/service/user_group_service.go @@ -89,7 +89,6 @@ func (s *UserGroupService) Update(id string, input dto.UserGroupCreateDto, allow group.Name = input.Name group.FriendlyName = input.FriendlyName - group.LdapID = &input.LdapID if err := s.db.Preload("Users").Save(&group).Error; err != nil { if errors.Is(err, gorm.ErrDuplicatedKey) { diff --git a/backend/resources/migrations/postgres/20250120102531_fix_empy_ldap_id_string.down.sql b/backend/resources/migrations/postgres/20250120102531_fix_empty_ldap_id_string.down.sql similarity index 100% rename from backend/resources/migrations/postgres/20250120102531_fix_empy_ldap_id_string.down.sql rename to backend/resources/migrations/postgres/20250120102531_fix_empty_ldap_id_string.down.sql diff --git a/backend/resources/migrations/postgres/20250120102531_fix_empy_ldap_id_string.up.sql b/backend/resources/migrations/postgres/20250120102531_fix_empty_ldap_id_string.up.sql similarity index 100% rename from backend/resources/migrations/postgres/20250120102531_fix_empy_ldap_id_string.up.sql rename to backend/resources/migrations/postgres/20250120102531_fix_empty_ldap_id_string.up.sql diff --git a/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.down.sql b/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.down.sql new file mode 100644 index 0000000..14da374 --- /dev/null +++ b/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.down.sql @@ -0,0 +1 @@ +UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; \ No newline at end of file diff --git a/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.up.sql b/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.up.sql new file mode 100644 index 0000000..87ee3e0 --- /dev/null +++ b/backend/resources/migrations/postgres/20250203082527_fix_empty_user_group_ldap_id_string.up.sql @@ -0,0 +1 @@ +UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; \ No newline at end of file diff --git a/backend/resources/migrations/sqlite/20250120102531_fix_empy_ldap_id_string.down.sql b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql similarity index 100% rename from backend/resources/migrations/sqlite/20250120102531_fix_empy_ldap_id_string.down.sql rename to backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql diff --git a/backend/resources/migrations/sqlite/20250120102531_fix_empy_ldap_id_string.up.sql b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql similarity index 100% rename from backend/resources/migrations/sqlite/20250120102531_fix_empy_ldap_id_string.up.sql rename to backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql diff --git a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql new file mode 100644 index 0000000..14da374 --- /dev/null +++ b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql @@ -0,0 +1 @@ +UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; \ No newline at end of file diff --git a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql new file mode 100644 index 0000000..87ee3e0 --- /dev/null +++ b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql @@ -0,0 +1 @@ +UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; \ No newline at end of file