You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 21_volume_migration.rb
    path of file: ./repos/kontena/server/db/migrations
    
    the code of the file until where you have to start completion: 
class VolumeMigration < Mongodb::Migration

  extend VolumesHelpers

  def self.up
    Volume.create_indexes

    GridService.each do |service|
      service.volumes.each do |v|
        begin
          volume_spec = parse_volume(v)
    
    
  def self.up
    Volume.create_indexes

    GridService.each do |service|
      service.volumes.each do |v|
        begin
          volume_spec = parse_volume(v)
        rescue
          next
        end
        if volume_spec[:volume]
          volume = service.grid.volumes.find_by(name: volume_spec[:volume])
          unless volume
            volume = Volume.create!(grid: service.grid, name: volume_spec[:volume], driver: 'local', scope: 'grid')
          end
          volume_spec[:volume] = volume
        end