title: using flask-migrate with flask-script, flask-socketio and application factory
body: <p>I'm creating an flask application with the application factory approach, but have an issue when using Flask-Migrate with socketio and flask-script.</p>
  
  <p>The problem is that I'm passing my <code>create_app</code> function to the <code>Manager</code> but I need to pass the <code>app</code> to my <code>socketio.run()</code> as well. And right now I can't seem to see a solution. Is there any way I can combine these two solutions?</p>
  
  <p>manage.py:</p>
  
  <pre><code>#app = create_app(False)  &lt;--- Old approach
  #manager = flask_script.Manager(app) 
  
  manager = flask_script.Manager(create_app)
  manager.add_option("-t", "--testing", dest="testing", required=False)
  
  manager.add_command("run", socketio.run(
      app,
      host='127.0.0.1',
      port=5000,
      use_reloader=False)
  )
  
  # DB Management
  manager.add_command("db", flask_migrate.MigrateCommand)
  </code></pre>
  
  <p>When I used the old approach with socketio, but without flask-migrate everything worked. If I use the new approach, and remove the socketio part, the migrate works.</p>
  
  <p>Note: I would like to be able to call my app with both of the following commands.
  <code>python manage.py run</code>
  <code>python manage.py -t True db upgrade</code></p>
  
  <p>Edit:</p>
  
  <p>Trying to use <code>current_app</code> I'm getting <code>RuntimeError: working outside of application context</code></p>
  
  <pre><code>manager.add_command("run", socketio.run(
     flask.current_app,
     host='127.0.0.1',
     port=5000,
     use_reloader=False)
  )
  </code></pre>