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

Go all the way with hardcoded values

Kabiru Mwenja0e77873f52fd
diff --git a/db/migrate/20250108100511_remove_incorrect_manage_own_reminders_permission.rb b/db/migrate/20250108100511_remove_incorrect_manage_own_reminders_permission.rb
index 8602188f556..a09982b076c 100644
--- a/db/migrate/20250108100511_remove_incorrect_manage_own_reminders_permission.rb
+++ b/db/migrate/20250108100511_remove_incorrect_manage_own_reminders_permission.rb
@@ -1,10 +1,14 @@
class RemoveIncorrectManageOwnRemindersPermission < ActiveRecord::Migration[7.1]
def up
# Remove manage_own_reminders permission from non member and anonymous roles
+ # Use hardcoded values for `Role::BUILTIN_NON_MEMBER` and `Role::BUILTIN_ANONYMOUS`
+ # to avoid breaking the migration if the values are changed in the future
+ non_member_builtin = 1 # Role::BUILTIN_NON_MEMBER
+ anonymous_builtin = 2 # Role::BUILTIN_ANONYMOUS
execute <<-SQL.squish
DELETE FROM role_permissions
WHERE role_id IN (
- SELECT id FROM roles WHERE builtin IN (#{Role::BUILTIN_NON_MEMBER}, #{Role::BUILTIN_ANONYMOUS})
+ SELECT id FROM roles WHERE builtin IN (#{non_member_builtin}, #{anonymous_builtin})
)
AND permission = 'manage_own_reminders'
SQL