models.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from django.db import models
  2. from glitchtip.base_models import CreatedModel
  3. class DebugSymbolBundle(CreatedModel):
  4. """
  5. Supports Artifact Bundles, Release Bundles, and DIFs
  6. """
  7. organization = models.ForeignKey(
  8. "organizations_ext.Organization", on_delete=models.CASCADE
  9. )
  10. debug_id = models.UUIDField(blank=True, null=True)
  11. last_used = models.DateTimeField(auto_now=True, db_index=True)
  12. release = models.ForeignKey(
  13. "releases.release",
  14. on_delete=models.SET_NULL,
  15. blank=True,
  16. null=True,
  17. )
  18. sourcemap_file = models.ForeignKey(
  19. "files.File", on_delete=models.SET_NULL, blank=True, null=True, related_name="+"
  20. )
  21. file = models.ForeignKey("files.File", on_delete=models.CASCADE)
  22. data = models.JSONField(default=dict)
  23. class Meta:
  24. constraints = [
  25. models.UniqueConstraint(
  26. fields=["organization", "debug_id"], name="unique_org_debug_id"
  27. ),
  28. models.UniqueConstraint(
  29. fields=["release", "file"], name="unique_release_file"
  30. ),
  31. models.CheckConstraint(
  32. check=models.Q(debug_id__isnull=False)
  33. | models.Q(release__isnull=False),
  34. name="debug_id_or_release_required",
  35. ),
  36. ]