1

When I try

alembic upgrade head

Alembic runs the previous migration script, obviously raising an error because my schema has changed.

In my database, I have version_num set to 48957fdfe8d5. After running

alembic revision -m '<my message>'

Alembic created the new script file—the one I want to run—with this at the top

revision = '28cc06993b73'
down_revision = '4d5f9ba76c5e'

In other words, everything looks good. So why is it clearly running the code in 4d5f9ba76c5e rather than 28cc06993b73? I have also tried

alembic upgrade 28cc06993b73

But it still runs the code in 4d5f9ba76c5e. Here is that log:

$ alembic upgrade 28cc06993b73
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
Starting in DEBUG mode
INFO  [alembic.migration] Running upgrade 48957fdfe8d5 -> 4d5f9ba76c5e, Breaking up metadata into required and optional

Also, if I check Alembic's history, I see that head is on 28cc06993b73:

$ alembic history
Starting in DEBUG mode
4d5f9ba76c5e -> 28cc06993b73 (head), creating soft file table
48957fdfe8d5 -> 4d5f9ba76c5e, Breaking up metadata into required and optional
<base> -> 48957fdfe8d5, Init

Thanks in advance.

jds
  • 7,910
  • 11
  • 63
  • 101

1 Answers1

0

Well firstly you said that your version number is 48957fdfe8d5 in the db so an upgrade from 48957fdfe8d5 -> 4d5f9ba76c5e is expected based on your alembic history.

You also say "Alembic runs the previous migration script, obviously raising an error because my schema has changed." What error is it showing? Did you manually change the db so that it reflects what is supposed to happen in 28cc06993b73? If that is the case then you could run

alembic stamp head

to get your db in sync with alembic migrations

karina
  • 805
  • 5
  • 10