mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-30 18:00:17 -06:00
Add check_migrations command
this way, at least in the Docker setup, you'll get a meaningful error when you try to start up a half-baked server
This commit is contained in:
@@ -32,4 +32,4 @@ RUN ["bugsink-manage", "migrate", "snappea", "--database=snappea"]
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD [ "monofy", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "gunicorn", "--bind=0.0.0.0:8000", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]
|
||||
CMD [ "monofy", "bugsink-manage", "check_migrations", "&&", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "gunicorn", "--bind=0.0.0.0:8000", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]
|
||||
|
||||
24
ingest/management/commands/check_migrations.py
Normal file
24
ingest/management/commands/check_migrations.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
Reference in New Issue
Block a user