Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create issue fingerprint table in postgres #25690

Merged
merged 12 commits into from
Oct 24, 2024
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")]
Loading