From 253c810300a3a80b7fbf0ff7950756d369215ec1 Mon Sep 17 00:00:00 2001 From: BelpHegoR17 Date: Mon, 8 Dec 2025 18:22:21 +0530 Subject: [PATCH] [qa] Use in-memory DB for migration checks #186 Use an isolated SQLite in-memory database when running the `makemigrations --dry-run` QA check. Fixes #186 --- openwisp-qa-check | 2 +- tests/openwisp2/settings.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/openwisp-qa-check b/openwisp-qa-check index 7ca185a2..27552749 100755 --- a/openwisp-qa-check +++ b/openwisp-qa-check @@ -162,7 +162,7 @@ runcheckpendingmigrations() { if [ ! -f "./tests/manage.py" ]; then echo "File manage.py not found, skipping Make Migration Check." else - OUTPUT=$(python tests/manage.py makemigrations --dry-run $MODULE) + OUTPUT=$(OWQA_USE_IN_MEMORY_DB=1 python tests/manage.py makemigrations --dry-run $MODULE) echo $OUTPUT | grep "No changes detected" &>/dev/null && echo "SUCCESS: Migrations check successful!" || { diff --git a/tests/openwisp2/settings.py b/tests/openwisp2/settings.py index 27038e9c..ace22cae 100644 --- a/tests/openwisp2/settings.py +++ b/tests/openwisp2/settings.py @@ -13,6 +13,14 @@ "NAME": "openwisp_utils.db", } } + +# Force in-memory DB for QA migration checks +if os.environ.get("OWQA_USE_IN_MEMORY_DB"): + DATABASES["default"] = { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", + } + if TESTING and "--exclude-tag=selenium_tests" not in sys.argv: DATABASES["default"]["TEST"] = { "NAME": os.path.join(BASE_DIR, "openwisp_utils_tests.db"),