Sha256: e72671bdb22a735d51048ea7a02f8ea42051e8d423666963bd584030f7f19696
Contents?: true
Size: 882 Bytes
Versions: 111
Compression:
Stored size: 882 Bytes
Contents
class RemoveGpgKeyPerms < ActiveRecord::Migration[6.0] def permission_map { Permission.find_by(name: :view_gpg_keys) => Permission.find_by(name: :view_content_credentials), Permission.find_by(name: :edit_gpg_keys) => Permission.find_by(name: :edit_content_credentials), Permission.find_by(name: :destroy_gpg_keys) => Permission.find_by(name: :destroy_content_credentials), Permission.find_by(name: :create_gpg_keys) => Permission.find_by(name: :create_content_credentials) } end def up perms = permission_map perms.each do |old_perm, new_perm| Filtering.where(permission_id: old_perm.id).update_all(:permission_id => new_perm.id) if old_perm end names = perms.keys.compact.map(&:name) Permission.where(:name => names).destroy_all if names.any? end def down fail ActiveRecord::IrreversibleMigration end end
Version data entries
111 entries across 111 versions & 1 rubygems