Hack around the "last migration doesn't stamp" Alembic bug (#967)

* Hack around the "last migration doesn't stamp" Alembic bug

This makes MySQL, Sqlite and Postgres work with a special hard coded
rule. I'm hoping Alembic fixes the root cause eventually.

* Running db upgrade twice in tests
This commit is contained in:
Maxime Beauchemin 2016-08-17 17:10:07 -07:00 committed by GitHub
parent 84213ab8cd
commit 23a5463208
3 changed files with 14 additions and 3 deletions

View File

@ -9,7 +9,7 @@
"scripts": {
"test": "npm run lint && mocha --compilers js:babel-core/register --required spec/helpers/browser.js spec/**/*_spec.*",
"dev": "NODE_ENV=dev webpack -d --watch --colors",
"prod": "NODE_ENV=production webpack -p --colors",
"prod": "NODE_ENV=production webpack -p --colors --progress",
"lint": "npm run --silent lint:js",
"lint:js": "eslint --ignore-path=.eslintignore --ext .js ."
},

View File

@ -72,11 +72,21 @@ def run_migrations_online():
poolclass=pool.NullPool)
connection = engine.connect()
kwargs = {}
if engine.name in ('sqlite', 'mysql'):
kwargs = {
'transaction_per_migration': True,
'transactional_ddl': True,
}
configure_args = current_app.extensions['migrate'].configure_args
if configure_args:
kwargs.update(configure_args)
context.configure(connection=connection,
target_metadata=target_metadata,
#compare_type=True,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args)
**kwargs)
try:
with context.begin_transaction():

View File

@ -1,9 +1,10 @@
#!/usr/bin/env bash
echo $DB
rm /tmp/caravel_unittests.db
rm ~/.caravel/caravel_unittests.db
rm -f .coverage
export CARAVEL_CONFIG=tests.caravel_test_config
set -e
caravel/bin/caravel db upgrade
caravel/bin/caravel db upgrade # running twice on purpose as a test
caravel/bin/caravel version -v
python setup.py nosetests