Skip to content

Commit

Permalink
Go all the way with hardcoded values
Browse files Browse the repository at this point in the history
  • Loading branch information
akabiru committed Jan 10, 2025
1 parent bd26eb2 commit 0e77873
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0e77873

Please sign in to comment.