# uplim/models.py from django.db import models from django.db.models import UniqueConstraint class Survey(models.Model): number = models.IntegerField(unique=True) def __str__(self): return f"Survey {self.number}" class Pixel(models.Model): #id = models.AutoField(primary_key=True) # ~2 million pixels for a 4096 survey survey = models.ForeignKey( Survey, on_delete=models.CASCADE, related_name='pixels', default=0 ) hpid = models.IntegerField(db_index=True) # up to over 200 million counts = models.IntegerField() # f4, up to ~44k integer: 2 byte too small exposure = models.FloatField() # f4, up to ~13300 float contaminated = models.BooleanField(default=False) class Meta: constraints = [ UniqueConstraint(fields=['survey','hpid'], name='unique_hpid_per_survey'), ] def __str__(self): return f"Pixel {self.id} (Survey {self.survey.number})"