From 510c96089db38a06e8faca850ba9518eabff27fe Mon Sep 17 00:00:00 2001 From: Kamal Date: Thu, 19 May 2016 11:33:47 +0100 Subject: [PATCH] Update to emit post migrate signal --- .../management/commands/sync_cassandra.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/django_cassandra_engine/management/commands/sync_cassandra.py b/django_cassandra_engine/management/commands/sync_cassandra.py index 84a1c29..c6d6fc1 100644 --- a/django_cassandra_engine/management/commands/sync_cassandra.py +++ b/django_cassandra_engine/management/commands/sync_cassandra.py @@ -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): @@ -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)