class RolesChangePermissionsToJson < ActiveRecord::Migration[6.1]

  def up
    say_with_time "Convert 'roles.permissions' YAML to JSON" do
      i = 0
      Symphonia::Role.where.not(permissions: nil).each do |role|
        yaml = product.read_attribute_before_type_cast :permissions
        next unless yaml.start_with? "---"

        role.update_columns permissions: YAML.safe_load(yaml)
        i += 1
      end

      i
    end
  end

end