def each_pending(dir)
      files = {}
      Scripts.all(dir).each do |path|
        name = File.basename(path)
        files[name] = path
      end

      scripts_previously_run(files.keys).each do |filename|
        files.delete(filename)
      end

      files.keys.sort.each do |filename|
        ## We have to recheck if this script is still pending. Some
        ## upgrade scripts may modify the scripts table themselves. This
        ## is actually useful in cases like when we migrated gilt from
        ## util_schema => schema_evolution_manager schema
        if !has_run?(filename)
          yield filename, files[filename]
        end
      end
    end
def each_pending(dir)
      files = {}
      Scripts.all(dir).each do |path|
        name = File.basename(path)
        files[name] = path
      end

      scripts_previously_run(files.keys).each do |filename|
        files.delete(filename)
      end

      files.keys.sort.each do |filename|
        ## We have to recheck if this script is still pending. Some
        ## upgrade scripts may modify the scripts table themselves. This
        ## is actually useful in cases like when we migrated gilt from
        ## util_schema => schema_evolution_manager schema
        if !has_run?(filename)
          yield filename, files[filename]
        end
      end
    end
For each sql script that needs to be applied to this database,
 yields a pair of |filename, fullpath| in proper order

 db = Db.new(host, user, name)
 scripts = Scripts.new(db)
 scripts.each_pending do |filename, path|
    puts filename
 end