0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/bin/migrate
Harry Waye 9bf86629df
feat(async-migrations): add auto complete trivial migrations option (#11601)
* feat(async-migrations): add auto complete trivial migrations option

This change is to ensure that the `run_async_migrations --check` command
option is a light operation such that we can safely use this e.g. in an
init container to gate the starting of a K8s Pod.

Previous to this change, the command was also handling the
auto-completion of migrations that it deamed to not be required, via the
`is_required` migration function. Aside from this heaviness issue, it's
good to avoid having side effects from a check command.

One part of the code that I wasn't sure about is the version checking,
so any comments here would be much appreciated.

Note that `./bin/migrate` is the command we call from both ECS migration
task and the Helm chart migration job.

* update comment re versions

* wip

* wip

* wip

* update hobby

* rename to noop migrations
2022-09-01 14:43:09 +00:00

18 lines
587 B
Bash
Executable File

#!/bin/bash
set -e
python manage.py migrate
python manage.py migrate_clickhouse
# 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
python manage.py sync_replicated_schema