Sha256: 1cba22bf32e8472df03c45366ae3889bc86b67c55fdb7963d7e28410cef7b90a

Contents?: true

Size: 587 Bytes

Versions: 22

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

class RenameWebhookPermissions < ActiveRecord::Migration[6.0]
  PERMISSIONS = {
    'view_webhook_targets' => 'view_webhooks',
    'create_webhook_targets' => 'create_webhooks',
    'edit_webhook_targets' => 'edit_webhooks',
    'destroy_webhook_targets' => 'destroy_webhooks'
  }.freeze

  def up
    PERMISSIONS.each do |from, to|
      Permission.unscoped.find_by(name: from)&.update_columns(name: to)
    end
  end

  def down
    PERMISSIONS.each do |from, to|
      Permission.unscoped.find_by(name: to)&.update_columns(name: from)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
foreman_webhooks-4.0.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.2.3 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.2.2 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.1.1 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.2.1 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.2.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.1.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.5 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-2.0.3 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.4 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-2.0.2 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.3 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.2 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.1 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-2.0.1 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-3.0.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-2.0.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-1.1.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-1.0.0 db/migrate/20200907232758_rename_webhook_permissions.rb
foreman_webhooks-0.0.3 db/migrate/20200907232758_rename_webhook_permissions.rb