From 6ce204fe3c3a41bb2ea20597d367155101a38265 Mon Sep 17 00:00:00 2001 From: Yakko Majuri <38760734+yakkomajuri@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:43:30 +0000 Subject: [PATCH] add version to person (#6628) * add version to person * add migration * set all initial version values to 0 * remove defaults * fix dep --- bin/start-backend | 2 +- latest_migrations.manifest | 2 +- posthog/migrations/0180_person_version.py | 14 ++++++++++++++ posthog/models/person.py | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 posthog/migrations/0180_person_version.py diff --git a/bin/start-backend b/bin/start-backend index 3926df3fd0b..56bdc6aecb4 100755 --- a/bin/start-backend +++ b/bin/start-backend @@ -1,4 +1,4 @@ #!/bin/bash set -e -python manage.py runserver \ No newline at end of file +python3 manage.py runserver \ No newline at end of file diff --git a/latest_migrations.manifest b/latest_migrations.manifest index 51a9acc5373..c6a1e3af468 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -3,7 +3,7 @@ auth: 0012_alter_user_first_name_max_length axes: 0006_remove_accesslog_trusted contenttypes: 0002_remove_content_type_name ee: 0005_project_based_permissioning -posthog: 0179_add_group_type_mapping +posthog: 0180_person_version rest_hooks: 0002_swappable_hook_model sessions: 0001_initial social_django: 0010_uid_db_index diff --git a/posthog/migrations/0180_person_version.py b/posthog/migrations/0180_person_version.py new file mode 100644 index 00000000000..134b562253b --- /dev/null +++ b/posthog/migrations/0180_person_version.py @@ -0,0 +1,14 @@ +# Generated by Django 3.2.5 on 2021-10-25 11:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("posthog", "0179_add_group_type_mapping"), + ] + + operations = [ + migrations.AddField(model_name="person", name="version", field=models.BigIntegerField(blank=True, null=True),) + ] diff --git a/posthog/models/person.py b/posthog/models/person.py index 13e08ea7eef..a4bf8656d24 100644 --- a/posthog/models/person.py +++ b/posthog/models/person.py @@ -78,6 +78,9 @@ class Person(models.Model): is_identified: models.BooleanField = models.BooleanField(default=False) uuid = models.UUIDField(db_index=True, default=UUIDT, editable=False) + # current version of the person, used to sync with ClickHouse and collapse rows correctly + version: models.BigIntegerField = models.BigIntegerField(null=True, blank=True) + # Has an index on properties -> email from migration 0121, (team_id, id DESC) from migration 0164