Skip to content

Commit

Permalink
Merge pull request #63 from kamal-una/master
Browse files Browse the repository at this point in the history
Update to emit post migrate signal
  • Loading branch information
r4fek committed Jun 1, 2016
2 parents f1e82d1 + 510c960 commit 8fd47ab
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions django_cassandra_engine/management/commands/sync_cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
sync_table
)
from django_cassandra_engine.utils import get_engine_from_db_alias
from django.apps import apps
from django.db.models.signals import post_migrate


def emit_post_migrate_signal(verbosity, interactive, db):
# Emit the post_migrate signal for every application.
for app_config in apps.get_app_configs():
if app_config.models_module is None:
continue
if verbosity >= 2:
print("Running post-migrate handlers for application %s" % app_config.label)
post_migrate.send(
sender=app_config,
app_config=app_config,
verbosity=verbosity,
interactive=interactive,
using=db)


class Command(NoArgsCommand):
Expand Down Expand Up @@ -93,3 +110,7 @@ def handle_noargs(self, **options):
if cassandra_alias is None:
raise CommandError(
'Please add django_cassandra_engine backend to DATABASES!')

# Send the post_migrate signal, so individual apps can do whatever they need
# to do at this point.
emit_post_migrate_signal(1, False, cassandra_alias)

0 comments on commit 8fd47ab

Please sign in to comment.