Skip to content

Commit

Permalink
Hotfix for Deleting sites with data
Browse files Browse the repository at this point in the history
Related to #574
Due to compression of the timeseriesresultvalues datatable, the command for deleting a site and cascading through various table fails when it arrives at the timeseriesresultvalues table, preventing the site from being deleting. This hot fix solution modifies the constraint so that on delete for timeseriesresultvalues will not cascade. This will result in orphaned timeseriesresultvalues in the database, so this solution is not ideal. Additional work is needed in the near future to develop methods for decompressing the tables and deleting the timeseriesresultvalues in cascade.
  • Loading branch information
ptomasula committed May 5, 2022
1 parent 0f07124 commit c0ef885
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dataloader/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Meta:

@python_2_unicode_compatible
class ExtendedResult(models.Model):
result = models.OneToOneField('Result', db_column='resultid', on_delete=models.CASCADE, primary_key=True)
result = models.OneToOneField('Result', db_column='resultid', on_delete=models.DO_NOTHING, primary_key=True)
spatial_reference = models.ForeignKey('SpatialReference', db_column='spatialreferenceid', on_delete=models.CASCADE, blank=True, null=True)

def __str__(self):
Expand Down Expand Up @@ -1997,7 +1997,7 @@ class Meta:


class TimeSeriesResultValue(ResultValue, QualityControlComponent, TimeAggregationComponent):
result = models.ForeignKey('TimeSeriesResult', related_name='values', db_column='resultid', on_delete=models.CASCADE)
result = models.ForeignKey('TimeSeriesResult', related_name='values', db_column='resultid', on_delete=models.DO_NOTHING)
data_value = models.FloatField(db_column='datavalue')
annotations = models.ManyToManyField('Annotation', related_name='annotated_time_series_values',
through='TimeSeriesResultValueAnnotation')
Expand Down

0 comments on commit c0ef885

Please sign in to comment.