mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-18 20:39:36 +02:00
Refactor migration to set end_date only if start_date is present; improve data integrity during migration process.
This commit is contained in:
parent
56b8b55b84
commit
1551fba9ab
1 changed files with 3 additions and 4 deletions
|
@ -1,12 +1,11 @@
|
|||
# Generated by Django 5.2.1 on 2025-05-27 16:38
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
def set_end_date_equal_to_start(apps, schema_editor):
|
||||
Visit = apps.get_model('adventures', 'Visit')
|
||||
for visit in Visit.objects.filter(end_date__isnull=True):
|
||||
visit.end_date = visit.start_date
|
||||
visit.save()
|
||||
if visit.start_date:
|
||||
visit.end_date = visit.start_date
|
||||
visit.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue