Sha256: f4b2c77f3cfb6363d4c71cbea86bbe6d0f2aaa6b0042128644d722b9ae05ca1f
Contents?: true
Size: 730 Bytes
Versions: 80
Compression:
Stored size: 730 Bytes
Contents
class RenameTemplateInvocationPermission < ActiveRecord::Migration[4.2] PERMISSION_NAMES = %w(execute_template_invocation create_template_invocations).freeze def up switch_filtering_permission!(*PERMISSION_NAMES) end def down switch_filtering_permission!(*PERMISSION_NAMES.reverse) end private def switch_filtering_permission!(old, new) old_permission = Permission.find_by(:name => old) return if old_permission.nil? new_permission = Permission.find_or_create_by(:name => new, :resource_type => 'TemplateInvocation') old_permission.filterings.each do |filtering| filtering.permission_id = new_permission.id filtering.save! end old_permission.destroy! end end
Version data entries
80 entries across 80 versions & 1 rubygems