This is the chain of events that has and is happening
- Day 0: I developed and deployed my app
- Day 1: I create the new database
- 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.
Currently I am at Day 3
There are plenty of documentations on how to get Flask-migrate running if you start from Day 0. You just call flask db init
, flask db migrate
and flask db upgrade
.
However, for my case, it's a bit different. I ran the commands, and my first version of migration is empty. 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.
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.
If I were to clone my repo from scratch:
flask db migrate
will result in alembic.util.exc.CommandError: Target database is not up to date.
.
flask db upgrade
will result in sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "offer" does not exist
.
What can I do to fix this?