Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Cascade delete Aliquot when parent Sample or Freezer Location is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronstephenson committed Feb 18, 2020
1 parent b4e4314 commit fa0adfe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions liliapi/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.2 on 2020-01-15 16:12
# Generated by Django 2.2.10 on 2020-02-18 15:37

import datetime
from decimal import Decimal
Expand Down Expand Up @@ -1603,9 +1603,9 @@ class Migration(migrations.Migration):
('aliquot_number', liliapi.models.NonnegativeIntegerField(validators=[django.core.validators.MinValueValidator(0)])),
('frozen', models.BooleanField(default=True)),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='aliquot_creator', to=settings.AUTH_USER_MODEL)),
('freezer_location', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='aliquots', to='liliapi.FreezerLocation')),
('freezer_location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aliquots', to='liliapi.FreezerLocation')),
('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='aliquot_modifier', to=settings.AUTH_USER_MODEL)),
('sample', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='aliquots', to='liliapi.Sample')),
('sample', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aliquots', to='liliapi.Sample')),
],
options={
'db_table': 'lili_aliquot',
Expand Down
4 changes: 2 additions & 2 deletions liliapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ def aliquot_string(self):
"""Returns the concatenated parent ID and child series number of the record"""
return '%s-%s' % (self.sample, self.aliquot_number)

sample = models.ForeignKey('Sample', models.PROTECT, related_name='aliquots')
freezer_location = models.ForeignKey('FreezerLocation', models.PROTECT, related_name='aliquots')
sample = models.ForeignKey('Sample', models.CASCADE, related_name='aliquots')
freezer_location = models.ForeignKey('FreezerLocation', models.CASCADE, related_name='aliquots')
aliquot_number = NonnegativeIntegerField()
frozen = models.BooleanField(default=True)
history = HistoricalRecords(inherit=True, table_name='lili_aliquothistory',
Expand Down

0 comments on commit fa0adfe

Please sign in to comment.