Sha256: 27a53c52d1ff7fcdfcc3310a684d46de6319ce6f3a58aadbdaff052df98ccc0c

Contents?: true

Size: 570 Bytes

Versions: 1

Compression:

Stored size: 570 Bytes

Contents

class AddPermissions < ActiveRecord::Migration[6.0]
  PERMISSIONS = [
    { 'name' => 'view_scc_products', 'resource_type' => 'SccProduct' },
    { 'name' => 'subscribe_scc_products', 'resource_type' => 'SccProduct' },
    { 'name' => 'test_connection_scc_accounts', 'resource_type' => 'SccAccount' }
  ].freeze

  def up
    PERMISSIONS.each do |p|
      Permission.find_or_create_by(:name => p['name'], :resource_type => p['resource_type'])
    end
  end

  def down
    PERMISSIONS.each do |p|
      Permission.where(:name => p['name']).destroy_all
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_scc_manager-1.8.10 db/migrate/20210713092440_add_permissions.rb