-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add match_action for plugin configs (#22177)
- Loading branch information
1 parent
79d309f
commit 7571f51
Showing
4 changed files
with
98 additions
and
4 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,86 @@ | ||
# Generated by Django 4.2.11 on 2024-05-06 09:46 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
# NOTE for future readers: This migration handles adding a constraint in a non-blocking way | ||
# Got this by running | ||
# DEBUG=1 python manage.py makemigrations | ||
# then | ||
# DEBUG=1 python manage.py sqlmigrate posthog 0412_pluginconfig_match_action | ||
# which output: | ||
### BEGIN; | ||
### -- | ||
### -- Add field match_action to pluginconfig | ||
### -- | ||
### ALTER TABLE "posthog_pluginconfig" ADD COLUMN "match_action_id" integer NULL CONSTRAINT "posthog_pluginconfig_match_action_id_1cbf8562_fk_posthog_a" REFERENCES "posthog_action"("id") DEFERRABLE INITIALLY DEFERRED; SET CONSTRAINTS "posthog_pluginconfig_match_action_id_1cbf8562_fk_posthog_a" IMMEDIATE; | ||
### CREATE INDEX "posthog_pluginconfig_match_action_id_1cbf8562" ON "posthog_pluginconfig" ("match_action_id"); | ||
### COMMIT; | ||
# and then modify the migration from the below commented version to a safe non-blocking version | ||
|
||
|
||
# # ORIGINIAL migration | ||
# class Migration(migrations.Migration): | ||
# dependencies = [ | ||
# ("posthog", "0411_eventproperty_indexes"), | ||
# ] | ||
|
||
# operations = [ | ||
# migrations.AddField( | ||
# model_name="pluginconfig", | ||
# name="match_action", | ||
# field=models.ForeignKey( | ||
# blank=True, | ||
# null=True, | ||
# on_delete=django.db.models.deletion.SET_NULL, | ||
# related_name="plugin_configs", | ||
# to="posthog.action", | ||
# ), | ||
# ), | ||
# ] | ||
|
||
|
||
class Migration(migrations.Migration): | ||
atomic = False # Added to support concurrent index creation | ||
dependencies = [ | ||
("posthog", "0414_personalapikey_mask_value"), | ||
] | ||
|
||
operations = [ | ||
migrations.SeparateDatabaseAndState( | ||
state_operations=[ | ||
migrations.AddField( | ||
model_name="pluginconfig", | ||
name="match_action", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="plugin_configs", | ||
to="posthog.action", | ||
), | ||
) | ||
], | ||
database_operations=[ | ||
# We add -- existing-table-constraint-ignore to ignore the constraint validation in CI. | ||
migrations.RunSQL( | ||
""" | ||
ALTER TABLE "posthog_pluginconfig" ADD COLUMN "match_action_id" integer NULL CONSTRAINT "posthog_pluginconfig_match_action_id_1cbf8562_fk_posthog_a" REFERENCES "posthog_action"("id") DEFERRABLE INITIALLY DEFERRED; -- existing-table-constraint-ignore | ||
SET CONSTRAINTS "posthog_pluginconfig_match_action_id_1cbf8562_fk_posthog_a" IMMEDIATE; -- existing-table-constraint-ignore | ||
""", | ||
reverse_sql=""" | ||
ALTER TABLE "posthog_pluginconfig" DROP COLUMN IF EXISTS "match_action_id"; | ||
""", | ||
), | ||
# We add CONCURRENTLY to the create command | ||
migrations.RunSQL( | ||
""" | ||
CREATE INDEX CONCURRENTLY "posthog_pluginconfig_match_action_id_1cbf8562" ON "posthog_pluginconfig" ("match_action_id"); | ||
""", | ||
reverse_sql=""" | ||
DROP INDEX IF EXISTS "posthog_pluginconfig_match_action_id_1cbf8562"; | ||
""", | ||
), | ||
], | ||
), | ||
] |
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