Skip to content

Commit

Permalink
Notify if there are no migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Marishka17 committed Jan 16, 2025
1 parent 603fe90 commit 0b49bbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cvat/apps/redis_handler/management/commands/migrateredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MIT

import sys
import traceback

from django.core.management.base import BaseCommand, CommandError
Expand All @@ -17,6 +18,10 @@ class Command(BaseCommand):
def handle(self, *args, **options) -> None:
loader = MigrationLoader()

if not loader:
self.stdout.write("No migrations to apply")
sys.exit(0)

for migration in loader:
try:
with transaction.atomic():
Expand Down
3 changes: 3 additions & 0 deletions cvat/apps/redis_handler/migration_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ def get_migration_class(self, app_name: str, migration_name: str) -> BaseRedisMi

def __iter__(self):
yield from self._unapplied_migrations

def __len__(self):
return len(self._unapplied_migrations)

0 comments on commit 0b49bbe

Please sign in to comment.