Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWELLS-2011] HOTFIX** edit migrations #2059

Merged
merged 1 commit into from
Nov 20, 2023
Merged
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 @@ -7,8 +7,16 @@ def populate_wells_with_attachment_table(apps, schema_editor):
# Get all well tag numbers that don't have an entry in WellAttachment
well_tag_numbers_without_attachment = Well.objects.exclude(wellattachment__isnull=False).values_list('well_tag_number', flat=True)

well_attachments_to_create = [WellAttachment(well_tag_number=tag_number) for tag_number in well_tag_numbers_without_attachment]
well_attachments_to_create = []

# Iterate through each tag number and create WellAttachment instances
for tag_number in well_tag_numbers_without_attachment:
well_instance = Well.objects.get(well_tag_number=tag_number)
well_attachment_instance = WellAttachment(well_tag_number=well_instance)
well_attachments_to_create.append(well_attachment_instance)

WellAttachment.objects.bulk_create(well_attachments_to_create)


class Migration(migrations.Migration):

Expand Down