This repository has been archived on 2021-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
greenlight/db/migrate/20191023172511_add_manage_r...

29 lines
799 B
Ruby

# frozen_string_literal: true
class MigrationProduct < ActiveRecord::Base
self.table_name = :roles
end
class SubMigrationProduct < ActiveRecord::Base
self.table_name = :role_permissions
end
class AddManageRoomRecordingsToPermissions < ActiveRecord::Migration[5.2]
def change
reversible do |dir|
dir.up do
MigrationProduct.all.each do |role|
SubMigrationProduct.create(role_id: role.id, name: "can_manage_rooms_recordings",
value: SubMigrationProduct.find_by(role_id: role.id, name: "can_manage_users").value, enabled: true)
end
end
dir.down do
MigrationProduct.all.each do |role|
SubMigrationProduct.find_by(role_id: role.id, name: "can_manage_rooms_recordings").destroy
end
end
end
end
end