-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor(taxonomy): Add project field to taxonomy models #26521
Changes from 8 commits
dd0e0d7
10a006e
7ec955b
de43aaf
92de540
52d2750
1c76d73
38a1242
606d3c0
ef91b56
6cca91d
b25fb29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Generated by Django 4.2.15 on 2024-10-29 12:15 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
from django.contrib.postgres.operations import AddIndexConcurrently | ||
from django.db.models.expressions import F, OrderBy | ||
from django.db.models.functions.comparison import Coalesce | ||
|
||
|
||
class Migration(migrations.Migration): | ||
atomic = False # Added to support concurrent index creation | ||
dependencies = [("posthog", "0525_hog_function_transpiled")] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
""" | ||
-- Add field project to eventdefinition | ||
ALTER TABLE "posthog_eventdefinition" ADD COLUMN "project_id" bigint NULL CONSTRAINT "posthog_eventdefinit_project_id_f93fcbb0_fk_posthog_p" REFERENCES "posthog_project"("id") DEFERRABLE INITIALLY DEFERRED; | ||
SET CONSTRAINTS "posthog_eventdefinit_project_id_f93fcbb0_fk_posthog_p" IMMEDIATE; | ||
-- Add field project to eventproperty | ||
ALTER TABLE "posthog_eventproperty" ADD COLUMN "project_id" bigint NULL CONSTRAINT "posthog_eventproperty_project_id_dd2337d2_fk_posthog_project_id" REFERENCES "posthog_project"("id") DEFERRABLE INITIALLY DEFERRED; | ||
SET CONSTRAINTS "posthog_eventproperty_project_id_dd2337d2_fk_posthog_project_id" IMMEDIATE; | ||
-- Add field project to propertydefinition | ||
ALTER TABLE "posthog_propertydefinition" ADD COLUMN "project_id" bigint NULL CONSTRAINT "posthog_propertydefi_project_id_d3eb982d_fk_posthog_p" REFERENCES "posthog_project"("id") DEFERRABLE INITIALLY DEFERRED; | ||
SET CONSTRAINTS "posthog_propertydefi_project_id_d3eb982d_fk_posthog_p" IMMEDIATE;""", | ||
reverse_sql=""" | ||
ALTER TABLE "posthog_eventdefinition" DROP COLUMN IF EXISTS "project_id"; | ||
ALTER TABLE "posthog_eventproperty" DROP COLUMN IF EXISTS "project_id"; | ||
ALTER TABLE "posthog_propertydefinition" DROP COLUMN IF EXISTS "project_id";""", | ||
state_operations=[ | ||
migrations.AddField( | ||
model_name="eventdefinition", | ||
name="project", | ||
field=models.ForeignKey( | ||
null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project" | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="eventproperty", | ||
name="project", | ||
field=models.ForeignKey( | ||
null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project" | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="propertydefinition", | ||
name="project", | ||
field=models.ForeignKey( | ||
null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project" | ||
), | ||
), | ||
], | ||
), | ||
AddIndexConcurrently( | ||
model_name="eventdefinition", | ||
index=models.Index(fields=["project"], name="posthog_eve_proj_id_f93fcbb0"), | ||
), | ||
AddIndexConcurrently( | ||
model_name="propertydefinition", | ||
index=models.Index(fields=["project"], name="posthog_prop_proj_id_d3eb982d"), | ||
), | ||
AddIndexConcurrently( | ||
model_name="propertydefinition", | ||
index=models.Index( | ||
F("project_id"), | ||
F("type"), | ||
Coalesce(F("group_type_index"), -1), | ||
OrderBy(F("query_usage_30_day"), descending=True, nulls_last=True), | ||
OrderBy(F("name")), | ||
name="index_property_def_query_proj", | ||
), | ||
), | ||
AddIndexConcurrently( | ||
model_name="propertydefinition", | ||
index=models.Index(fields=["project_id", "type", "is_numerical"], name="posthog_pro_project_3583d2_idx"), | ||
), | ||
AddIndexConcurrently( | ||
model_name="eventproperty", | ||
index=models.Index(fields=["project"], name="posthog_eve_proj_id_dd2337d2"), | ||
), | ||
AddIndexConcurrently( | ||
model_name="eventproperty", | ||
index=models.Index(fields=["project", "event"], name="posthog_eve_proj_id_22de03_idx"), | ||
), | ||
AddIndexConcurrently( | ||
model_name="eventproperty", | ||
index=models.Index(fields=["project", "property"], name="posthog_eve_proj_id_26dbfb_idx"), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0525_hog_function_transpiled | ||
0526_project_field_in_taxonomy |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only types need to be updated in the plugin server, since these records are SELECTed with
*