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(persons): add max_version to the pg cleanup queue (#111245)

Eli Reisman9154560c3db2
diff --git a/rust/persons_migrations/20261003000001_add_max_version_to_person_pg_cleanup_queue.sql b/rust/persons_migrations/20261003000001_add_max_version_to_person_pg_cleanup_queue.sql
new file mode 100644
index 000000000000..2036898b88cf
--- /dev/null
+++ b/rust/persons_migrations/20261003000001_add_max_version_to_person_pg_cleanup_queue.sql
@@ -0,0 +1,10 @@
+-- The highest ClickHouse person version the sweep removed; the drain deletes the Postgres person only at or below it.
+--
+-- SAFE: nullable column with no default, so catalog-only; lock_timeout bounds the ACCESS EXCLUSIVE wait. Idempotent.
+
+SET LOCAL lock_timeout = '2s';
+
+ALTER TABLE person_pg_cleanup_queue ADD COLUMN IF NOT EXISTS max_version BIGINT;
+
+COMMENT ON COLUMN person_pg_cleanup_queue.max_version IS
+ 'Highest ClickHouse person version the sweep removed. The drain deletes the Postgres person only at or below this version. NULL when no sweep recorded a bound; the drain leaves those rows in place.';