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.

feat(workflows): Switch cyclotron_jobs.person_id from UUID to TEXT (#59094)

Daniel Marchuk84318fbc9753
diff --git a/rust/cyclotron-node-migrations/20260519000001_replace_person_id_with_text.sql b/rust/cyclotron-node-migrations/20260519000001_replace_person_id_with_text.sql
new file mode 100644
index 000000000000..912265e0700f
--- /dev/null
+++ b/rust/cyclotron-node-migrations/20260519000001_replace_person_id_with_text.sql
@@ -0,0 +1,10 @@
+-- The wait-until-event feature is not yet live, so we drop existing data and
+-- re-create the column as TEXT so non-UUID person identifiers (UUIDT, group keys)
+-- flow through without coercion.
+--
+-- DROP + ADD in a single ALTER keeps the column atomic from other sessions'
+-- view: they see the table either with the old UUID column or with the new TEXT
+-- column, never with no `person_id` at all. The dependent index is dropped here
+-- and recreated CONCURRENTLY in the next migration.
+SET lock_timeout = '5s';
+ALTER TABLE cyclotron_jobs DROP COLUMN IF EXISTS person_id, ADD COLUMN person_id TEXT;
diff --git a/rust/cyclotron-node-migrations/20260519000002_add_person_id_index.sql b/rust/cyclotron-node-migrations/20260519000002_add_person_id_index.sql
new file mode 100644
index 000000000000..ca7a7db5c025
--- /dev/null
+++ b/rust/cyclotron-node-migrations/20260519000002_add_person_id_index.sql
@@ -0,0 +1,4 @@
+-- no-transaction
+CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_cyclotron_jobs_person_id
+ ON cyclotron_jobs (team_id, person_id)
+ WHERE person_id IS NOT NULL;