diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index e781c3f092ab5..40a3c59e023c8 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -173,7 +173,7 @@ jobs: if: needs.changes.outputs.backend == 'true' timeout-minutes: 10 - name: Validate Django migrations + name: Validate Django and CH migrations runs-on: depot-ubuntu-latest-4 steps: @@ -231,6 +231,9 @@ jobs: # initial migrations (0001_*) as these are guaranteed to be # run on initial setup where there is no data. git diff --name-status origin/master..HEAD | grep "A\sposthog/migrations/" | awk '{print $2}' | grep -v migrations/0001_ | python manage.py test_migrations_are_safe + + - name: Check CH migrations + run: | # Same as above, except now for CH looking at files that were added in posthog/clickhouse/migrations/ git diff --name-status origin/master..HEAD | grep "A\sposthog/clickhouse/migrations/" | awk '{print $2}' | python manage.py test_ch_migrations_are_safe diff --git a/posthog/management/commands/test_ch_migrations_are_safe.py b/posthog/management/commands/test_ch_migrations_are_safe.py index 55f90aeb11e11..c6f341e9eb1fc 100644 --- a/posthog/management/commands/test_ch_migrations_are_safe.py +++ b/posthog/management/commands/test_ch_migrations_are_safe.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) repo_path = os.getcwd() repo = Repo(repo_path) -current_branch = repo.active_branch.name +current_sha = repo.head.object.hexsha class Command(BaseCommand): @@ -22,7 +22,7 @@ def run_and_check_migration(new_migration): repo.git.checkout("master") old_migration_files = os.listdir("posthog/clickhouse/migrations") old_migrations = [] - repo.git.checkout(current_branch) + repo.git.checkout(current_sha) for migration in old_migration_files: match = re.findall(r"([0-9]+)_([a-zA-Z_0-9]+)\.py", migration)