Skip to content

Commit

Permalink
Hack around the "last migration doesn't stamp" Alembic bug (#967)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mistercrunch committed Aug 18, 2016
1 parent 84213ab commit 23a5463
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion caravel/assets/package.json
Expand Up @@ -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 ."
},
Expand Down
12 changes: 11 additions & 1 deletion caravel/migrations/env.py
Expand Up @@ -72,11 +72,21 @@ def process_revision_directives(context, revision, directives):
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():
Expand Down
3 changes: 2 additions & 1 deletion run_tests.sh
@@ -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

0 comments on commit 23a5463

Please sign in to comment.