Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.db import migrations

from core.redis import start_job_async_or_sync
from core.utils.iterators import iterate_queryset

logger = logging.getLogger(__name__)
migration_name = __name__
Expand All @@ -36,7 +35,7 @@ def forward_migration_job(*, migration_name: str) -> None:
migration.save()

try:
views = iterate_queryset(View.objects.all())
views = View.objects.all()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Memory risk: Using View.objects.all() directly loads all View objects into memory. Use View.objects.all().iterator() to process in chunks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ Performance: Replacing iterate_queryset() with .all() loads all View objects into memory at once, which can cause memory issues or timeouts in production databases with many views. Use iterate_queryset() for safe chunked iteration.

updated_count = 0

for view in views:
Expand Down Expand Up @@ -75,7 +74,7 @@ def reverse_migration_job(*, migration_name: str) -> None:

logger.info(f'Starting reverse migration {migration_name}')

views = iterate_queryset(View.objects.all())
views = View.objects.all()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Same memory risk in reverse migration. Use View.objects.all().iterator() instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡ Performance: Same issue as forward migration - use iterate_queryset() instead of .all() to handle large querysets safely.

updated_count = 0

for view in views:
Expand Down
Loading