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(migrate): schedule temporal workflows on production deploys (#67005)

Sven Langee3a5eeff858b
diff --git a/bin/migrate b/bin/migrate
index 1d32a1eab5e7..024de78e0888 100755
--- a/bin/migrate
+++ b/bin/migrate
@@ -216,14 +216,31 @@ fi
if [ -n "$CLICKHOUSE_PID" ]; then
wait $CLICKHOUSE_PID
CLICKHOUSE_WAIT_STATUS=$?
-
+
CH_STATUS=$(cat $CLICKHOUSE_STATUS)
rm -f $CLICKHOUSE_STATUS
-
+
if [ "$CH_STATUS" != "0" ] || [ $CLICKHOUSE_WAIT_STATUS -ne 0 ]; then
echo "Error in ClickHouse migrations, exiting."
exit 1
fi
fi
+# Temporal worker schedules. Skipped on hobby deploys (no Temporal cluster) and
+# on local dev (DEBUG=1, matching the persons-migration gate above).
+# Non-fatal: scheduling is reconciled idempotently on every deploy, so a
+# transient Temporal outage should not block the migrate job.
+if run_scope "temporal-schedules"; then
+ if [ "${DEPLOYMENT:-}" != "hobby" ] && [ "${DEBUG:-0}" != "1" ]; then
+ echo "Scheduling Temporal worker workflows..."
+ # timeout guards against an unreachable Temporal frontend: the client has
+ # no connect/RPC deadline of its own, so a network black-hole would hang
+ # the whole migrate job otherwise. 90s leaves room for Django startup on a
+ # cold container; reconciliation is idempotent so a killed run resumes next deploy.
+ if ! timeout 90 python manage.py schedule_temporal_workflows; then
+ echo "Warning: schedule_temporal_workflows failed, continuing."
+ fi
+ fi
+fi
+
echo "All migrations completed successfully."