Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(growth): drop UserProductList reason columns (#90621)

Rafael Audibert280f46f744e3
diff --git a/posthog/migrations/1340_drop_userproductlist_reason_columns.py b/posthog/migrations/1340_drop_userproductlist_reason_columns.py
new file mode 100644
index 000000000000..9e70aa1d6a2c
--- /dev/null
+++ b/posthog/migrations/1340_drop_userproductlist_reason_columns.py
@@ -0,0 +1,34 @@
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ """Drop the `reason` / `reason_text` columns from posthog_userproductlist.
+
+ Migration 1328 already removed them from Django's model state, so nothing reads
+ or writes them any more. This is the second phase from safe-django-migrations.md
+ "Dropping Columns": deploy the state removal, wait a full deploy cycle, then drop.
+
+ `DROP COLUMN` takes a brief ACCESS EXCLUSIVE lock on posthog_userproductlist.
+ That table is not on the hot-table list, and the drop is metadata-only, so the
+ lock is held for microseconds once it is granted.
+
+ Irreversible: the column data is gone. `reverse_sql` re-adds empty nullable
+ columns so the migration can be unapplied, but it cannot bring the values back.
+ """
+
+ dependencies = [
+ ("posthog", "1339_validate_taggeditem_project_fk"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="""
+ ALTER TABLE "posthog_userproductlist" DROP COLUMN IF EXISTS "reason";
+ ALTER TABLE "posthog_userproductlist" DROP COLUMN IF EXISTS "reason_text";
+ """,
+ reverse_sql="""
+ ALTER TABLE "posthog_userproductlist" ADD COLUMN IF NOT EXISTS "reason" varchar(32) NULL;
+ ALTER TABLE "posthog_userproductlist" ADD COLUMN IF NOT EXISTS "reason_text" text NULL;
+ """,
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index d3750d0b1c1d..fefdac453cf4 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1339_validate_taggeditem_project_fk
+1340_drop_userproductlist_reason_columns