I recently executed flask db migrate
and got an exception in between (details). The migration was only partially done.
What I did
The migration looked like this:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
...
op.add_column('users', sa.Column('registered_on', sa.DateTime(), nullable=False))
...
Everything before the "registered_on" was done. Everything below was not. When I executed flask db upgrade
again, it complained that the columns before already existed.
Next, I tried flask db downgrade
and then flask db upgrade
. That worked, but now all the data is lost (not too bad, it was a development environment).
What should I have done to not delete all data from the database, after the migration ran only partially?