On 04/18/2016 10:56 AM, bertr...@cryptosense.com wrote:
Hi,

Here's something quite fundamental I don't understand about alembic.
I've initialized my database and created a revision meant to be executed
online.  I went like this:
|
alembic init app/alembic
# edit configuration
alembic revision -m 'Data modification'
# edit revision script
alembic upgrade
|

If I run alembic upgrade a second time, it runs the upgradefunction
again, which results in an error because my function should not be run
on the new database (it's not idempotent). Why doesn't alembic figure
out that the upgrade has already been applied? This is especially
annoying in production where I just want to make sure the database is up
to date without having to guess which revision script to execute.

I'm not understanding what you are actually doing. It is an error to run "alembic upgrade" without a target:

$ alembic upgrade
usage: alembic upgrade [-h] [--sql] [--tag TAG] revision
alembic upgrade: error: too few arguments


When you specify a target, say "head", it updates the version table:
        
$ .venv/bin/alembic upgrade head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> e12f6fb70dcc, rev 1

and then the next time, it will do nothing:

$ .venv/bin/alembic upgrade head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.


so it appears like you have some entirely customized setup going on, which itself would be where your issue lies.








Best,

--
Bertrand

--
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+unsubscr...@googlegroups.com
<mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to