Add migration test (#4398)

* Add migration test

Looking at older data migration which removes stock items which are "scheduled_for_deletion"

* Account for parent / child relationships
This commit is contained in:
Oliver authored and GitHub committed 2023-02-23 23:12:48 +11:00
1 parent 93ce55298f
commit 89ac0a623b
2 files changed
+69 -1

No files matched your search

@@ -22,7 +22,13 @@ def delete_scheduled(apps, schema_editor):
if items.count() > 0:
logger.info(f"Removing {items.count()} stock items scheduled for deletion")
items.delete()
# Ensure any parent / child relationships are updated!
for item in items:
childs = StockItem.objects.filter(parent=item)
childs.update(parent=item.parent)
item.delete()
Task = apps.get_model('django_q', 'schedule')