Skip to content

Commit

Permalink
Fix "paster db init" when celery is configured with a backend other t…
Browse files Browse the repository at this point in the history
…han database.
  • Loading branch information
David Read committed Jul 21, 2015
1 parent e711c1d commit 08d63d0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ckan/model/__init__.py
Expand Up @@ -217,13 +217,18 @@ def init_db(self):
try:
import ckan.lib.celery_app as celery_app
import celery.db.session as celery_session
## This creates the database tables it is a slight
## hack to celery.
import celery.backends.database
## This creates the database tables (if using that backend)
## It is a slight hack to celery
backend = celery_app.celery.backend
celery_result_session = backend.ResultSession()
engine = celery_result_session.bind
celery_session.ResultModelBase.metadata.create_all(engine)
if isinstance(backend,
celery.backends.database.DatabaseBackend):
celery_result_session = backend.ResultSession()
engine = celery_result_session.bind
celery_session.ResultModelBase.metadata.\
create_all(engine)
except ImportError:
# use of celery is optional
pass

self.init_configuration_data()
Expand Down

0 comments on commit 08d63d0

Please sign in to comment.