Sha256: ec04716998fdda19d3f67fdd3497f03591acaae0fe3d3424f71dc0f62884462f

Contents?: true

Size: 620 Bytes

Versions: 4

Compression:

Stored size: 620 Bytes

Contents

class FixSccPermissions < ActiveRecord::Migration[5.2]
  PERMISSION_NAMES = {
    :view_scc => :view_scc_accounts,
    :use_scc => :use_scc_accounts,
    :new_scc => :new_scc_accounts,
    :edit_scc => :edit_scc_accounts,
    :delete_scc => :delete_scc_accounts,
    :sync_scc => :sync_scc_accounts,
  }.freeze

  def up
    PERMISSION_NAMES.each do |old_n, new_n|
      Permission.find_by(name: old_n)&.update(name: new_n, resource_type: 'SccAccount')
    end
  end

  def down
    PERMISSION_NAMES.each do |old_n, new_n|
      Permission.find_by(name: new_n)&.update(name: old_n, resource_type: nil)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_scc_manager-4.0.0 db/migrate/20200520281300_fix_scc_permissions.rb
foreman_scc_manager-3.1.1 db/migrate/20200520281300_fix_scc_permissions.rb
foreman_scc_manager-3.1.0 db/migrate/20200520281300_fix_scc_permissions.rb
foreman_scc_manager-3.0.0 db/migrate/20200520281300_fix_scc_permissions.rb