2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

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
2023-02-23 23:12:48 +11:00
committed by GitHub
parent 93ce55298f
commit 89ac0a623b
2 changed files with 69 additions and 1 deletions

View File

@ -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')