Skip to content

Commit

Permalink
chore: create issue fingerprint table in postgres (#25690)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored and timgl committed Oct 25, 2024
1 parent 719ae53 commit 1329a09
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion latest_migrations.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contenttypes: 0002_remove_content_type_name
ee: 0016_rolemembership_organization_member
otp_static: 0002_throttling
otp_totp: 0002_auto_20190420_0723
posthog: 0497_experimentholdout_experiment_holdout
posthog: 0498_errortrackingissuefingerprint_and_more
sessions: 0001_initial
social_django: 0010_uid_db_index
two_factor: 0007_auto_20201201_1019
33 changes: 33 additions & 0 deletions posthog/migrations/0498_errortrackingissuefingerprint_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.2.15 on 2024-10-24 13:21

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("posthog", "0497_experimentholdout_experiment_holdout"),
]

operations = [
migrations.CreateModel(
name="ErrorTrackingIssueFingerprint",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("fingerprint", models.TextField()),
("version", models.BigIntegerField(blank=True, default=0)),
(
"issue",
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.errortrackinggroup"),
),
(
"team",
models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
),
],
),
migrations.AddConstraint(
model_name="errortrackingissuefingerprint",
constraint=models.UniqueConstraint(fields=("team", "fingerprint"), name="unique fingerprint for team"),
),
]
11 changes: 11 additions & 0 deletions posthog/models/error_tracking/error_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,14 @@ def convert_fingerprints_to_tuples(fps: list[list[str]]):
# converting back to list of lists before saving
self.merged_fingerprints = [list(f) for f in merged_fingerprints]
self.save()


class ErrorTrackingIssueFingerprint(models.Model):
team = models.ForeignKey("Team", on_delete=models.CASCADE, db_index=False)
issue = models.ForeignKey(ErrorTrackingGroup, on_delete=models.CASCADE)
fingerprint = models.TextField(null=False, blank=False)
# current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table
version = models.BigIntegerField(blank=True, default=0)

class Meta:
constraints = [models.UniqueConstraint(fields=["team", "fingerprint"], name="unique fingerprint for team")]

0 comments on commit 1329a09

Please sign in to comment.