Skip to content

Commit

Permalink
feat: Add migration in advance of session properties PR (#21703)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c authored Apr 24, 2024
1 parent 8c299f1 commit a3466b3
Show file tree
Hide file tree
Showing 4 changed files with 51 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: 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
1 change: 1 addition & 0 deletions mypy-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
2 changes: 2 additions & 0 deletions posthog/models/property_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PropertyType(models.TextChoices):
String = "String", "String"
Numeric = "Numeric", "Numeric"
Boolean = "Boolean", "Boolean"
Duration = "Duration", "Duration"


class PropertyFormat(models.TextChoices):
Expand All @@ -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,
Expand Down

0 comments on commit a3466b3

Please sign in to comment.