summaryrefslogtreecommitdiffstats
path: root/db/migrate/20241103184550_change_builtin_roles_user_visibility.rb
blob: 4e8b0f7f39e79b54db0e54a3e385792f40e5f27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class ChangeBuiltinRolesUserVisibility < ActiveRecord::Migration[7.2]
  def up
    # Default to members_of_visible_projects for all newly created roles
    change_column_default :roles, :users_visibility, 'members_of_visible_projects'

    # Set the users visibility of the builtin roles (Anonymous and Non-Member)
    # to members_of_visible_projects as a saf(er) default.
    Role.where.not(builtin: 0).update_all(users_visibility: 'members_of_visible_projects')
  end

  def down
    change_column_default :roles, :users_visibility, 'all'
  end
end