Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add migration to run the inherited service with the correct project_id

Oliver Günthere9a211d0aa8a
diff --git a/db/migrate/20240131130134_fix_inherited_group_memberships.rb b/db/migrate/20240131130134_fix_inherited_group_memberships.rb
new file mode 100644
index 00000000000..282947cb158
--- /dev/null
+++ b/db/migrate/20240131130134_fix_inherited_group_memberships.rb
@@ -0,0 +1,20 @@
+class FixInheritedGroupMemberships < ActiveRecord::Migration[7.0]
+ def up
+ # Recreate member_roles for all group members
+ # due to regression https://community.openproject.org/work_packages/52528
+ Group
+ .where(id: Member.where(project_id: nil, user_id: Group.select(:id)).select(:user_id))
+ .find_each do |group|
+
+ warn "Creating inherited roles for group ##{group.id}"
+
+ Groups::CreateInheritedRolesService
+ .new(group, current_user: User.system, contract_class: EmptyContract)
+ .call(user_ids: group.user_ids, send_notifications: false, project_ids: nil)
+ end
+ end
+
+ def down
+ # Nothing to do
+ end
+end