title: Using alembic with multiple databases
body: <p>I have a pretty standard flask app. It uses <code>flask_sqlalchemy</code> to manage connections to a <code>postgres</code> server and <code>alembic</code> to manage migrations.</p>
  
  <p>Now the issue is that I'm in the process of integrating it with another project and that means that I'm trying to allow it to pull a single model from another database. Luckily, <code>flask_sqlalchemy</code> has great support for this with the <code>SQLALCHEMY_BINDS</code> flag. So I have my app with a new model set up like so:</p>
  
  <pre><code>class CoreUser(UserMixin, db.Model):
      __bind_key__ = 'core'
  
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String(255), unique=True)
  </code></pre>
  
  <p>So far so good. My app now checks this other database when it should. Here's the minus though. Since I'm using <code>alembic</code> to actually manage all of the schemas in the database, when I run my typical <code>alembic revision --autogenerate</code> script, it doesn't actually do anything to this second database at all, and seems to just ignore the <code>__bind_key__</code> piece of the puzzle.</p>
  
  <p>Instead, it sets up the proper <code>core_user</code> relation in the first database. How can I indicate to alembic that when it encounters this schema definition it should be creating the relation in a different database?</p>
  
  <p>I've tried updating my <code>alembic.ini</code> file as shown below on the advice of <a href="https://groups.google.com/forum/#!topic/sqlalchemy/cCTXejFWX9o" rel="noreferrer">this</a> (ancient) thread:</p>
  
  <pre><code>[core_db]
  sqlalchemy.url = &lt;DATABASE_URI&gt;
  script_location = alembic
  </code></pre>
  
  <p>And then running the following commands:</p>
  
  <pre><code>alembic -n core_db revision --autogenerate
  alembic -n core_db upgrade head
  </code></pre>
  
  <p>And while the revision is generated and this doesn't fail, there are no relations actually created in the database indicated by the <code>core_db</code> <code>sqlalchemy.url</code> parameter.</p>
  
  <p>I haven't been able to find any better documentation than that 4 year old Google group thread, but my current approach doesn't seem to be working and I don't have any obvious next steps. I'm unable to find the appropriate <code>alembic</code> documentation, but this seems like a very simple and common use case, so I can't imagine that this isn't supported.</p>
  
  <p>Any advice?</p>