From 4a7da86718d7dfd9a6095ba15da25a2ea6479b3c Mon Sep 17 00:00:00 2001 From: David Newell Date: Fri, 18 Oct 2024 16:57:19 +0100 Subject: [PATCH 1/8] chore: create issue fingerprint table in postgres --- latest_migrations.manifest | 2 +- ..._errortrackingissuefingerprint_and_more.py | 33 +++++++++++++++++++ .../models/error_tracking/error_tracking.py | 12 +++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 posthog/migrations/0494_errortrackingissuefingerprint_and_more.py diff --git a/latest_migrations.manifest b/latest_migrations.manifest index 990fb689cec15..22a1e0e1aebe2 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -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: 0493_insightvariable_values +posthog: 0494_errortrackingissuefingerprint_and_more sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 diff --git a/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py new file mode 100644 index 0000000000000..19f9d6848f9ab --- /dev/null +++ b/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.15 on 2024-10-18 15:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + dependencies = [ + ("posthog", "0493_insightvariable_values"), + ] + + operations = [ + migrations.CreateModel( + name="ErrorTrackingIssueFingerprint", + fields=[ + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("fingerprint", models.CharField(max_length=400)), + ("version", models.BigIntegerField(blank=True, null=True)), + ( + "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"), + ), + ] diff --git a/posthog/models/error_tracking/error_tracking.py b/posthog/models/error_tracking/error_tracking.py index 1007e12699863..3a619a2bf173e 100644 --- a/posthog/models/error_tracking/error_tracking.py +++ b/posthog/models/error_tracking/error_tracking.py @@ -58,3 +58,15 @@ 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.CharField(max_length=400) + + # current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table + version = models.BigIntegerField(null=True, blank=True) + + class Meta: + constraints = [models.UniqueConstraint(fields=["team", "fingerprint"], name="unique fingerprint for team")] From bd84ab3ad83e23ada0348a86e024edc688f1b2de Mon Sep 17 00:00:00 2001 From: David Newell Date: Mon, 21 Oct 2024 14:34:44 +0100 Subject: [PATCH 2/8] remove migration file --- ..._errortrackingissuefingerprint_and_more.py | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 posthog/migrations/0494_errortrackingissuefingerprint_and_more.py diff --git a/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py deleted file mode 100644 index 19f9d6848f9ab..0000000000000 --- a/posthog/migrations/0494_errortrackingissuefingerprint_and_more.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 4.2.15 on 2024-10-18 15:56 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - dependencies = [ - ("posthog", "0493_insightvariable_values"), - ] - - operations = [ - migrations.CreateModel( - name="ErrorTrackingIssueFingerprint", - fields=[ - ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), - ("fingerprint", models.CharField(max_length=400)), - ("version", models.BigIntegerField(blank=True, null=True)), - ( - "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"), - ), - ] From 54d427dbed7ee83281b6b8a979001460267bd7f2 Mon Sep 17 00:00:00 2001 From: David Newell Date: Mon, 21 Oct 2024 14:41:08 +0100 Subject: [PATCH 3/8] non nullable, default --- latest_migrations.manifest | 2 +- ..._errortrackingissuefingerprint_and_more.py | 33 +++++++++++++++++++ .../models/error_tracking/error_tracking.py | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 posthog/migrations/0495_errortrackingissuefingerprint_and_more.py diff --git a/latest_migrations.manifest b/latest_migrations.manifest index f8f13e49ea0ad..cea13a5526499 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -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: 0494_team_project_non_null +posthog: 0495_errortrackingissuefingerprint_and_more sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 diff --git a/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py new file mode 100644 index 0000000000000..948e045443a0a --- /dev/null +++ b/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.15 on 2024-10-21 13:39 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + dependencies = [ + ("posthog", "0494_team_project_non_null"), + ] + + operations = [ + migrations.CreateModel( + name="ErrorTrackingIssueFingerprint", + fields=[ + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("fingerprint", models.CharField(max_length=400)), + ("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"), + ), + ] diff --git a/posthog/models/error_tracking/error_tracking.py b/posthog/models/error_tracking/error_tracking.py index 3a619a2bf173e..d55d7ce4c43aa 100644 --- a/posthog/models/error_tracking/error_tracking.py +++ b/posthog/models/error_tracking/error_tracking.py @@ -66,7 +66,7 @@ class ErrorTrackingIssueFingerprint(models.Model): fingerprint = models.CharField(max_length=400) # current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table - version = models.BigIntegerField(null=True, blank=True) + version = models.BigIntegerField(blank=True, default=0) class Meta: constraints = [models.UniqueConstraint(fields=["team", "fingerprint"], name="unique fingerprint for team")] From 73d9d007623029af371df210168cbf49eec42831 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 22 Oct 2024 10:24:43 +0100 Subject: [PATCH 4/8] textfield --- .../migrations/0495_errortrackingissuefingerprint_and_more.py | 4 ++-- posthog/models/error_tracking/error_tracking.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py index 948e045443a0a..fd67cd1f192e0 100644 --- a/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py +++ b/posthog/migrations/0495_errortrackingissuefingerprint_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.15 on 2024-10-21 13:39 +# Generated by Django 4.2.15 on 2024-10-22 09:23 from django.db import migrations, models import django.db.models.deletion @@ -14,7 +14,7 @@ class Migration(migrations.Migration): name="ErrorTrackingIssueFingerprint", fields=[ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), - ("fingerprint", models.CharField(max_length=400)), + ("fingerprint", models.TextField()), ("version", models.BigIntegerField(blank=True, default=0)), ( "issue", diff --git a/posthog/models/error_tracking/error_tracking.py b/posthog/models/error_tracking/error_tracking.py index d55d7ce4c43aa..7e4c625446520 100644 --- a/posthog/models/error_tracking/error_tracking.py +++ b/posthog/models/error_tracking/error_tracking.py @@ -63,8 +63,7 @@ def convert_fingerprints_to_tuples(fps: list[list[str]]): 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.CharField(max_length=400) - + 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) From 5d9614383f4caed168387425c399ba1605e41cfb Mon Sep 17 00:00:00 2001 From: David Newell Date: Wed, 23 Oct 2024 14:27:55 +0100 Subject: [PATCH 5/8] update dependency --- .../migrations/0496_errortrackingissuefingerprint_and_more.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posthog/migrations/0496_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0496_errortrackingissuefingerprint_and_more.py index fd67cd1f192e0..ce5da83ad2ef6 100644 --- a/posthog/migrations/0496_errortrackingissuefingerprint_and_more.py +++ b/posthog/migrations/0496_errortrackingissuefingerprint_and_more.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ("posthog", "0494_team_project_non_null"), + ("posthog", "0495_alter_batchexportbackfill_start_at_and_more"), ] operations = [ From 6d65757ef26847184ec4720f21d39c971db76e70 Mon Sep 17 00:00:00 2001 From: David Newell Date: Wed, 23 Oct 2024 14:29:16 +0100 Subject: [PATCH 6/8] fix latest migrations --- latest_migrations.manifest | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/latest_migrations.manifest b/latest_migrations.manifest index 035c0bacc9a60..cde2c39d0062d 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -5,8 +5,7 @@ contenttypes: 0002_remove_content_type_name ee: 0016_rolemembership_organization_member otp_static: 0002_throttling otp_totp: 0002_auto_20190420_0723 -posthog: 0495_errortrackingissuefingerprint_and_more -posthog: 0495_alter_batchexportbackfill_start_at_and_more +posthog: 0496_errortrackingissuefingerprint_and_more sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 From 95cd74ca887f828624c9dfb1042b87c03026ca40 Mon Sep 17 00:00:00 2001 From: David Newell Date: Thu, 24 Oct 2024 14:19:14 +0100 Subject: [PATCH 7/8] fix merges --- latest_migrations.manifest | 4 ---- 1 file changed, 4 deletions(-) diff --git a/latest_migrations.manifest b/latest_migrations.manifest index e91ffd6dfb389..8842f6c11851d 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -5,11 +5,7 @@ contenttypes: 0002_remove_content_type_name ee: 0016_rolemembership_organization_member otp_static: 0002_throttling otp_totp: 0002_auto_20190420_0723 -<<<<<<< HEAD -posthog: 0496_errortrackingissuefingerprint_and_more -======= posthog: 0497_experimentholdout_experiment_holdout ->>>>>>> master sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 From 885eda752acd58113450c296b90bcd65c35d119a Mon Sep 17 00:00:00 2001 From: David Newell Date: Thu, 24 Oct 2024 14:22:50 +0100 Subject: [PATCH 8/8] update files --- latest_migrations.manifest | 2 +- .../migrations/0498_errortrackingissuefingerprint_and_more.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/latest_migrations.manifest b/latest_migrations.manifest index 8842f6c11851d..706c12ae7f1ef 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -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 diff --git a/posthog/migrations/0498_errortrackingissuefingerprint_and_more.py b/posthog/migrations/0498_errortrackingissuefingerprint_and_more.py index 8ac3440e3cc27..cae2e30d9feea 100644 --- a/posthog/migrations/0498_errortrackingissuefingerprint_and_more.py +++ b/posthog/migrations/0498_errortrackingissuefingerprint_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.15 on 2024-10-22 09:23 +# Generated by Django 4.2.15 on 2024-10-24 13:21 from django.db import migrations, models import django.db.models.deletion