diff --git a/app/models/concerns/has_group_relation_definition.rb b/app/models/concerns/has_group_relation_definition.rb index 51426aebc..ac376751e 100644 --- a/app/models/concerns/has_group_relation_definition.rb +++ b/app/models/concerns/has_group_relation_definition.rb @@ -14,8 +14,7 @@ module HasGroupRelationDefinition validates :access, presence: true validate :validate_access - after_save :touch_related - after_destroy :touch_related + after_commit :touch_related end private diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 6c5d8ce84..7b2125f82 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -178,6 +178,7 @@ class CreateBase < ActiveRecord::Migration[4.2] add_index :groups_users, [:user_id] add_index :groups_users, [:group_id] add_index :groups_users, [:access] + add_index :groups_users, %i[user_id group_id access] add_foreign_key :groups_users, :users add_foreign_key :groups_users, :groups diff --git a/db/migrate/20220131135531_issue3940_add_index.rb b/db/migrate/20220131135531_issue3940_add_index.rb new file mode 100644 index 000000000..aa5ec184f --- /dev/null +++ b/db/migrate/20220131135531_issue3940_add_index.rb @@ -0,0 +1,10 @@ +# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ + +class Issue3940AddIndex < ActiveRecord::Migration[6.0] + def change + # return if it's a new setup + return if !Setting.exists?(name: 'system_init_done') + + add_index :groups_users, %i[user_id group_id access] + end +end