-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(taxonomy): Add project field to taxonomy models (#26521)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8d3e2bd
commit caaf6a0
Showing
15 changed files
with
217 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", "0527_project_name_sync")] | ||
|
||
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"), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0527_project_name_sync | ||
0528_project_field_in_taxonomy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...defs-rs/.sqlx/query-04abdef9c07ae1a30bb6f22abcfb4dcdf2e218e48e0fd8a247e1b7ae0f04aee3.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...defs-rs/.sqlx/query-2b9a8c4b8d323e1673d805125b4073799ecba84594ca04cfb24481cffbf6f6ca.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...defs-rs/.sqlx/query-9e0e25b9966a23792427c27a80888a75efdb8abe195339e0a1676ebed6fc61ef.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...defs-rs/.sqlx/query-c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.