How do you add migrate an existing database with alembic/flask-migrate if you did not start off with it? : <p>This is the chain of events that has and is happening</p>

<ul>
<li>Day 0: I developed and deployed my app  </li>
<li>Day 1: I create the new database </li>
<li>Day 3: I realized I wanted to add a new row to my existing table. I found flask-migrate and I want to use it to migrate my database.</li>
</ul>

<p>Currently I am at Day 3</p>

<p>There are plenty of documentations on how to get Flask-migrate running if you start from Day 0. You just call <code>flask db init</code>, <code>flask db migrate</code> and <code>flask db upgrade</code>. </p>

<p>However, for my case, it's a bit different. I ran the commands, and my first version of migration is <em>empty</em>. Then I modified my database schema and generated a new migration. Now my latest migration only has 1 line of migration which is adding the new row to the table. </p>

<p>I realized that none of my migrations have the actual schema to create the database, which is supposed to be the first migration you see if you start flask-migrate on day 1.</p>

<p><strong>If I were to clone my repo from scratch:</strong> </p>

<p><code>flask db migrate</code> will result in <code>alembic.util.exc.CommandError: Target database is not up to date.</code>. </p>

<p><code>flask db upgrade</code> will result in <code>sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "offer" does not exist</code>. </p>

<p>What can I do to fix this? </p>
