def apply!(dir)
      Preconditions.check_state(File.directory?(dir),
                                "Dir[%s] does not exist" % dir)

      count = 0
      @scripts.each_pending(dir) do |filename, path|
        count += 1
        if @dry_run
          puts "[DRY RUN] Applying #{filename}"
          puts path
          puts ""
        else
          print "Applying #{filename}"
          @db.psql_file(filename, path)
          @scripts.record_as_run!(filename)
          puts " Done"
        end
      end
      count
    end
def apply!(dir)
      Preconditions.check_state(File.directory?(dir),
                                "Dir[%s] does not exist" % dir)

      count = 0
      @scripts.each_pending(dir) do |filename, path|
        count += 1
        if @dry_run
          puts "[DRY RUN] Applying #{filename}"
          puts path
          puts ""
        else
          print "Applying #{filename}"
          @db.psql_file(filename, path)
          @scripts.record_as_run!(filename)
          puts " Done"
        end
      end
      count
    end
Applies scripts in order, returning number of scripts applied