docs: def upgrade():
      """ This takes a *really* long time.  Like, hours. """
  
      config_paths = context.config.get_main_option('fedmsg_config_dir')
      filenames = fedmsg.config._gather_configs_in(config_paths)
  
      config = fedmsg.config.load_config(filenames=filenames)
  
      make_processors(**config)
  
      engine = op.get_bind().engine
      m.init(engine=engine)
      for msg in _page(m.Message.query.order_by(m.Message.timestamp)):
          print("processing %s %s" % (msg.timestamp, msg.topic))
  
          if msg.users and msg.packages:
              continue
  
          changed = False
  
          if not msg.users:
              new_usernames = msg2usernames(msg.__json__(), **config)
              print("Updating users to %r" % new_usernames)
              changed = changed or new_usernames
              for new_username in new_usernames:
                  new_user = m.User.get_or_create(new_username)
                  msg.users.append(new_user)
  
          if not msg.packages:
              new_packagenames = msg2packages(msg.__json__(), **config)
              print("Updating packages to %r" % new_packagenames)
              changed = changed or new_usernames
              for new_packagename in new_packagenames:
                  new_package = m.Package.get_or_create(new_packagename)
                  msg.packages.append(new_package)
  
          if changed and random.random() < 0.01:
              # Only save if something changed.. and only do it every so often.
              # We do this so that if we crash, we can kind of pick up where
              # we left off.  But if we do it on every change: too slow.
              print(" * Saving!")
              m.session.commit()
  
      m.session.commit()