Files
bugsink/bsmain/management/commands/check_migrations.py
Klaas van Schelven ae9cb209a5 Create 'bsmain' (for bugsink-main) app to hold commands
As had been noted on some of the commands, 'ingest' was not the best place for
them.  However, [project-level apps are not supported in
Django](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/2)
So just create a 'main' app. I want to qualify it as 'myproject-main' though, to avoid
further unqualified global namespace pollution. And I want to avoid prefixing with 'bugsink'
b/c that's annoying for tab-completion. So 'bs' it is.

I've moved all commands over; even though a case could be made that the "feeding" commands
(raise_exception, send_json, stress_test) are somewhat related to ingestion, that's not
a very good case :-)
2025-01-23 11:55:34 +01:00

25 lines
964 B
Python

from django.core.management import call_command
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Calls `migrate` with `check_unapplied=True` to check for unapplied migrations (2 DBs, adds error message)"
def handle(self, *args, **options):
try:
call_command('migrate', check_unapplied=True)
except SystemExit:
self.stdout.write(self.style.ERROR(
"You have unapplied migrations. Make sure to call `bugsink-manage migrate` before running the server."
))
raise
try:
call_command('migrate', "snappea", check_unapplied=True, database="snappea")
except SystemExit:
self.stdout.write(self.style.ERROR(
"You have unapplied migrations. Make sure to call `bugsink-manage migrate snappea --database=snappea` "
"before running the server."
))
raise