Skip to content

Commit 8fd47ab

Browse files
committed
Merge pull request #63 from kamal-una/master
Update to emit post migrate signal
2 parents f1e82d1 + 510c960 commit 8fd47ab

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

django_cassandra_engine/management/commands/sync_cassandra.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@
1010
sync_table
1111
)
1212
from django_cassandra_engine.utils import get_engine_from_db_alias
13+
from django.apps import apps
14+
from django.db.models.signals import post_migrate
15+
16+
17+
def emit_post_migrate_signal(verbosity, interactive, db):
18+
# Emit the post_migrate signal for every application.
19+
for app_config in apps.get_app_configs():
20+
if app_config.models_module is None:
21+
continue
22+
if verbosity >= 2:
23+
print("Running post-migrate handlers for application %s" % app_config.label)
24+
post_migrate.send(
25+
sender=app_config,
26+
app_config=app_config,
27+
verbosity=verbosity,
28+
interactive=interactive,
29+
using=db)
1330

1431

1532
class Command(NoArgsCommand):
@@ -93,3 +110,7 @@ def handle_noargs(self, **options):
93110
if cassandra_alias is None:
94111
raise CommandError(
95112
'Please add django_cassandra_engine backend to DATABASES!')
113+
114+
# Send the post_migrate signal, so individual apps can do whatever they need
115+
# to do at this point.
116+
emit_post_migrate_signal(1, False, cassandra_alias)

0 commit comments

Comments
 (0)