OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/db/migrate/20211101152840_redistribute...

32 lines
715 B

class RedistributeEditProjectPermission < ActiveRecord::Migration[6.1]
def up
add_permission('select_custom_fields')
add_permission('select_done_status')
end
def down
remove_permission('select_custom_fields')
remove_permission('select_done_status')
end
private
def add_permission(name)
execute <<~SQL.squish
INSERT INTO
role_permissions
(permission, role_id, created_at, updated_at)
SELECT '#{name}', role_id, NOW(), NOW()
FROM role_permissions
WHERE permission = 'edit_project'
SQL
end
def remove_permission(name)
execute <<~SQL.squish
DELETE FROM
role_permissions
WHERE permission = '#{name}'
SQL
end
end