alembic migration upgrade throws UnboundExecutionError:
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Barbican |
Fix Released
|
Medium
|
Venkat Sundaram |
Bug Description
I tried to upgrade my barbican db (mysql) from the initial version "1a0c2cdafb38" to "13d127569afa" using the script bin/barbican-
This is per instructions in the "Manually" section of the wiki: https:/
$ bin/barbican-
2014-06-05 05:26:58.753 921 CRITICAL barbican-db-manage [-] UnboundExecutio
upon investigation, traced the issue to the following lines in the file: barbican/
def upgrade():
meta = sa.MetaData()
>> meta.reflect(
if 'secret_
---snipped----
rep._ENGINE was None and hence the error. If I comment these three lines, the alembic create table operation succeeds.
Questions:
1. Am I doing something wrong in running the migration script ?
2. In another setup (non-development box), I don't even see the barbican-
3. The data migration wiki says that the check for the table's existence is required to guard against the same migration code called at the start of the api server. Isn't the alembic versioning approach intended to solve this exact problem ? I mean, just plugin the "upgrade"
def upgrade():
ctx = op.get_context()
con = op.get_bind()
table_exists = ctx.dialect.
if not table_exists:
---snipped----
Is there any reason not to use the existing alembic context (which is already inside a transaction) like this ?
Thanks
Changed in barbican: | |
status: | Fix Committed → Fix Released |
Changed in barbican: | |
milestone: | juno-1 → 2014.2 |
Changed in barbican: | |
importance: | Undecided → Medium |
Hello Venkat, just responding to your questions above...
I'm assuming you are referring to this wiki: https:/ /github. com/cloudkeep/ barbican/ wiki/Database- Migrations
1) You are running the script as expected, but if the automatic mode is enabled (so when Barbican boots it auto upgrades the database) then it shouldn't be required.
2) If it is not in the setup.cfg file, then that's an oversight, good catch!
3) As for checking for table existence, I think the issue stems from SQLAlchemy synching vs Alembic version processing. There are conditions in which the two modes seem to fight each other. At any rate, it seems your code suggestion is actually the better approach than what was added to the migration wiki.
Would you be up for modifying the current failing migration module with your suggested code changes (per this bug), and then updating that section of the wiki to favor using your approach? Would you also be up for adding a CR to add the migration script to the setup.cfg file?