Discussion:
Error when autogenerate migration scripts with alembic
Ons
2014-11-17 15:20:12 UTC
Permalink
Hi,

I want to use alembic to auto-generate migrations scripts for my postgres
db. When i tried:
#alembic upgrade and alembic downgrade both worked properly, but when i
modified my models and tried
#alembic revision --autogenerate it raises this error :

INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
ERROR [alembic.util] Target database is not up to date.
FAILED: Target database is not up to date.

In env.py, i imported my models and set target_metadata to
myModels.Base.metadata.

Anyone has an idea on how to solve this issue or what is causing the error
above ?

Thanks.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Bayer
2014-11-17 15:27:33 UTC
Permalink
Hi,
#alembic upgrade and alembic downgrade both worked properly, but when i modified my models and tried
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
ERROR [alembic.util] Target database is not up to date.
FAILED: Target database is not up to date.
In env.py, i imported my models and set target_metadata to myModels.Base.metadata.
Anyone has an idea on how to solve this issue or what is causing the error above ?
when you run alembic revision with —autogenerate, the database has to be up-to-date. This means that the most “head” version that is in your versions/ directory must be the same version that is in your database in the “alembic_version” table.

So this means one of two things:

1. you need to run alembic upgrade

2. there is a version file in your versions/ directory that you don’t actually want, like you ran alembic revision already, it created a file, and you don’t actually want that file, you’d delete it first.

you can run “alembic history” to see all the versions that are in your versions/ directory in order.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ons
2014-11-17 15:38:47 UTC
Permalink
It worked. Thank you for your great explanation.
Post by Ons
Post by Ons
Hi,
I want to use alembic to auto-generate migrations scripts for my
#alembic upgrade and alembic downgrade both worked properly, but when i
modified my models and tried
Post by Ons
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
ERROR [alembic.util] Target database is not up to date.
FAILED: Target database is not up to date.
In env.py, i imported my models and set target_metadata to
myModels.Base.metadata.
Post by Ons
Anyone has an idea on how to solve this issue or what is causing the
error above ?
when you run alembic revision with —autogenerate, the database has to be
up-to-date. This means that the most “head” version that is in your
versions/ directory must be the same version that is in your database in
the “alembic_version” table.
1. you need to run alembic upgrade
2. there is a version file in your versions/ directory that you don’t
actually want, like you ran alembic revision already, it created a file,
and you don’t actually want that file, you’d delete it first.
you can run “alembic history” to see all the versions that are in your
versions/ directory in order.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...