-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
After migrating from MariaDB to PostgreSQL in v1.7.0, Transient objects can no longer be deleted in the expected way, using for example Transient.objects.get(name='2021abcd').delete(), because the cascading deletion of associated objects (Cutout, Aperture, SEDFittingResult, etc) does not occur. Instead, errors like the following are shown:
django.db.utils.IntegrityError: update or delete on table "host_cutout" violates foreign key constraint "host_aperture_cutout_id_13ce5cd4_fk_host_cutout_id" on table "host_aperture"
DETAIL: Key (id)=(1220837) is still referenced from table "host_aperture".
Until a correction to the database is devised, a workaround is to manually remove these objects using clunky code like this:
print(f'''Deleting transient "{transient.name}"...''')
objs = StarFormationHistoryResult.objects.filter(transient__name=transient.name)
for obj in objs:
print(f'''{obj}''')
obj.delete()
objs = SEDFittingResult.objects.filter(transient__name=transient.name)
for obj in objs:
print(f'''{obj.model_file}''')
obj.delete()
objs = Aperture.objects.filter(transient__name=transient.name)
for obj in objs:
print(f'''{obj.name}''')
obj.delete()
objs = Cutout.objects.filter(transient__name=transient.name)
for obj in objs:
print(f'''{obj.name}''')
obj.delete()
transient.delete()Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working