title: No changes detected in Alembic autogeneration of migrations with Flask-SQLAlchemy
body: <p>I'm having trouble getting Alembic to autogenerate candidate migrations from changes to classes using <code>db.Model</code> (Flask-SQLAlchemy) instead of <code>Base</code>.</p>
  
  <p>I've modified <code>env.py</code> to create my Flask app, import all relevant models, initialize the database, and then run migrations:</p>
  
  <pre><code>...
  uri = 'mysql://user:password@host/dbname?charset=utf8'
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = uri
  app.config['SQLALCHEMY_ECHO'] = True
  db.init_app(app)
  with app.test_request_context():
      target_metadata = db.Model.metadata
      config.set_main_option('sqlalchemy.url', uri)
      if context.is_offline_mode():
          run_migrations_offline()
      else:
          run_migrations_online()
  ...
  </code></pre>
  
  <p>This approach works fine for <code>drop_all()</code>, <code>create_all()</code> (for example, when recreating a test db for unit testing), but it seems to fall flat in this case. The auto generated version scripts always have empty upgrade and downgrade methods, <em>e.g.</em>,</p>
  
  <pre><code>def upgrade():
      ### commands auto generated by Alembic - please adjust! ###
      pass
      ### end Alembic commands ###
  
  
  def downgrade():
      ### commands auto generated by Alembic - please adjust! ###
      pass
      ### end Alembic commands ###
  </code></pre>
  
  <p>My changes have included renaming columns, changing column definitions, <em>etc</em>., not just changes to indices and foreign keys.</p>
  
  <p>Is anyone out there using Alembic with Flask-SQLAlchemy? Any idea where I'm going wrong?</p>
  
  <p>Thanks much!</p>