Skip to content

Commit

Permalink
fix: avoid altering PostgreSQL role while running in xdist
Browse files Browse the repository at this point in the history
These are executed in parallel and can cause tests to fail.
  • Loading branch information
nijel committed Feb 24, 2025
1 parent 8537b5b commit 5108c4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ cleanup_database() {
fi
psql --host="$CI_DB_HOST" -c 'DROP DATABASE IF EXISTS weblate;' -U postgres
psql --host="$CI_DB_HOST" -c 'CREATE DATABASE weblate;' -U postgres
# Replaces weblate/utils/migrations/0001_alter_role.py
psql --host="$CI_DB_HOST" -c 'ALTER ROLE postgres SET timezone = UTC;' -U postgres
fi
}

Expand Down
7 changes: 6 additions & 1 deletion weblate/utils/migrations/0001_alter_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

# Generated by Django 3.1.1 on 2020-10-19 12:16

import os

from django.db import migrations


def alter_role(apps, schema_editor) -> None:
if schema_editor.connection.vendor != "postgresql":
if (
schema_editor.connection.vendor != "postgresql"
or "PYTEST_XDIST_TESTRUNUID" in os.environ
):
return

settings = schema_editor.connection.settings_dict
Expand Down

0 comments on commit 5108c4e

Please sign in to comment.