Files
posthog/bin/migrate
2025-02-05 12:32:11 +01:00

29 lines
951 B
Bash
Executable File

#!/bin/bash
set -e
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
# NOTE when running in docker, rust might not exist so we need to check for it
if [ -d "$SCRIPT_DIR/../rust/bin" ]; then
bash $SCRIPT_DIR/../rust/bin/migrate-cyclotron
fi
(
python manage.py migrate_clickhouse
python manage.py sync_replicated_schema
) & # ClickHouse migrations can run in parallel to Postgres ones
python manage.py migrate
# NOTE: we do not apply any non-noop migrations here. Rather these are run
# manually within the UI. See https://posthog.com/docs/runbook/async-migrations
# for details.
python manage.py run_async_migrations --complete-noop-migrations
# NOTE: this check should not fail if a migration isn't complete but within the
# given async migration posthog version range, thus this should not block e.g.
# k8s pod deployments.
python manage.py run_async_migrations --check
wait $(jobs -p) # Make sure CH migrations are done before we exit