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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add migration in order to add share_calendars permission to all roles having the view_calendar permission
Jonas Jabari019ad346d5b6
diff --git a/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rb b/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rbnew file mode 100644index 00000000000..f3cf43341ff--- /dev/null+++ b/modules/calendar/db/migrate/20230607101213_populate_share_calendar_role_permission.rb@@ -0,0 +1,20 @@+class PopulateShareCalendarRolePermission < ActiveRecord::Migration[7.0]+ def up+ # From https://community.openproject.org/projects/openproject/work_packages/15339/activity+ # -> For the migration path, all the roles that has the setting "View calendars" active will+ # also by default have "Subscribe to iCalendars" active+ role_ids_with_view_calendar_permission = RolePermission.where(permission: "view_calendar").distinct(:role_id).pluck(:role_id)++ new_permissions = role_ids_with_view_calendar_permission.map do |role_id|+ { role_id:, permission: "share_calendars" }+ end++ RolePermission.insert_all(new_permissions)+ end++ def down+ # Question: is following down migration desired? I tend to not include that as it (in theory) might+ # remove manually set share_calendar permissions+ # RolePermission.where(permission: "share_calendars").delete_all+ end+end