title: Can't migrate or upgrade database with Flask-Migrate (Alembic)
body: <p>I've been using Flask-Migrate (Alembic) for updating my database. I updated my <code>models.py</code> file however I made an error. I ran a migration and went to upgrade the database, however I got this error:</p>
  
  <pre><code>sqlalchemy.exc.IntegrityError: (_mysql_exceptions.IntegrityError) (1215, 'Cannot add foreign key constraint') [SQL: u'\nCREATE TABLE topics (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\t`subjectID` INTEGER, \n\ttopic VARCHAR(150) NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(`subjectID`) REFERENCES subjects (id)\n)\n\n']
  </code></pre>
  
  <p>What I had done was have <code>db.Text</code> instead of <code>db.Integer</code> for a foreign key.</p>
  
  <p>When I try run a new migration I get this:</p>
  
  <pre><code>alembic.util.CommandError: Target database is not up to date.
  </code></pre>
  
  <p>So now I'm stuck. I cannot upgrade the database nor run a migration. I tried to downgrade to an older database version by using something like this:</p>
  
  <pre><code>python manage.py db downgrade --sql b877018671c:36949b1cca31
  </code></pre>
  
  <p>But when I run <code>python manage.py db current</code> I get the newest database version which I am stuck in.</p>
  
  <p>Is there a fix for this? Thanks.</p>