-
-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BuildItem with empty BuildLine reference
- Loading branch information
1 parent
108bd28
commit e1d5d10
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/backend/InvenTree/build/migrations/0049_alter_builditem_build_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 4.2.12 on 2024-05-08 01:38 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('build', '0048_build_project_code'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='builditem', | ||
name='build_line', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='build.buildline'), | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
src/backend/InvenTree/build/migrations/0050_auto_20240508_0138.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.12 on 2024-05-08 01:38 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forward(apps, schema_editor): | ||
"""Find and delete any BuildItem instances which have a null BuildLine field.""" | ||
|
||
BuildItem = apps.get_model('build', 'BuildItem') | ||
|
||
items = BuildItem.objects.filter(build_line=None) | ||
|
||
if items.count() > 0: | ||
print(f"Deleting {items.count()} BuildItem objects with null BuildLine field") | ||
items.delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('build', '0049_alter_builditem_build_line'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward, reverse_code=migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters