diff --git a/latest_migrations.manifest b/latest_migrations.manifest index dac9ed4ce4539..ede9b35bf2662 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: 0403_plugin_has_private_access +posthog: 0404_remove_propertydefinition_property_type_is_valid_and_more sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 diff --git a/mypy-baseline.txt b/mypy-baseline.txt index 3c6bbf22089c0..9b607b6222cd3 100644 --- a/mypy-baseline.txt +++ b/mypy-baseline.txt @@ -366,6 +366,7 @@ posthog/session_recordings/queries/session_recording_list_from_replay_summary.py posthog/session_recordings/queries/session_recording_list_from_replay_summary.py:0: note: If the method is meant to be abstract, use @abc.abstractmethod posthog/session_recordings/queries/session_recording_list_from_replay_summary.py:0: error: Missing return statement [empty-body] posthog/session_recordings/queries/session_recording_list_from_replay_summary.py:0: note: If the method is meant to be abstract, use @abc.abstractmethod +posthog/migrations/0404_remove_propertydefinition_property_type_is_valid_and_more.py:0: error: Module "django.contrib.postgres.operations" has no attribute "AddConstraintNotValid" [attr-defined] posthog/hogql_queries/test/test_query_runner.py:0: error: Variable "TestQueryRunner" is not valid as a type [valid-type] posthog/hogql_queries/test/test_query_runner.py:0: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases posthog/hogql_queries/test/test_query_runner.py:0: error: Invalid base class "TestQueryRunner" [misc] diff --git a/posthog/migrations/0404_remove_propertydefinition_property_type_is_valid_and_more.py b/posthog/migrations/0404_remove_propertydefinition_property_type_is_valid_and_more.py new file mode 100644 index 0000000000000..ac34ed62af7b9 --- /dev/null +++ b/posthog/migrations/0404_remove_propertydefinition_property_type_is_valid_and_more.py @@ -0,0 +1,47 @@ +# Generated by Django 4.2.11 on 2024-04-21 21:11 +from django.contrib.postgres.operations import AddConstraintNotValid +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("posthog", "0403_plugin_has_private_access"), + ] + + operations = [ + migrations.RemoveConstraint( + model_name="propertydefinition", + name="property_type_is_valid", + ), + migrations.AlterField( + model_name="propertydefinition", + name="property_type", + field=models.CharField( + blank=True, + choices=[ + ("DateTime", "DateTime"), + ("String", "String"), + ("Numeric", "Numeric"), + ("Boolean", "Boolean"), + ("Duration", "Duration"), + ], + max_length=50, + null=True, + ), + ), + migrations.AlterField( + model_name="propertydefinition", + name="type", + field=models.PositiveSmallIntegerField( + choices=[(1, "event"), (2, "person"), (3, "group"), (4, "session")], default=1 + ), + ), + # changed from migrations.AddConstraint. See migration 0405 for where we validate the constraint + AddConstraintNotValid( + model_name="propertydefinition", + constraint=models.CheckConstraint( + check=models.Q(("property_type__in", ["DateTime", "String", "Numeric", "Boolean", "Duration"])), + name="property_type_is_valid", + ), + ), + ] diff --git a/posthog/models/property_definition.py b/posthog/models/property_definition.py index 0a6f89354a639..8c8b9d6c773b4 100644 --- a/posthog/models/property_definition.py +++ b/posthog/models/property_definition.py @@ -12,6 +12,7 @@ class PropertyType(models.TextChoices): String = "String", "String" Numeric = "Numeric", "Numeric" Boolean = "Boolean", "Boolean" + Duration = "Duration", "Duration" class PropertyFormat(models.TextChoices): @@ -34,6 +35,7 @@ class Type(models.IntegerChoices): EVENT = 1, "event" PERSON = 2, "person" GROUP = 3, "group" + SESSION = 4, "session" team: models.ForeignKey = models.ForeignKey( Team,