diff --git a/features/environment.py b/features/environment.py index 7d06891c7..b65b880c3 100644 --- a/features/environment.py +++ b/features/environment.py @@ -213,8 +213,13 @@ def _install_template_db_patch() -> None: # Only copy template for databases that don't exist yet or are empty # (SQLite auto-creates a 0-byte file on first engine open). + # If the DB already exists and is non-empty, it was either copied from + # the template or created by a prior step — either way it is already + # fully migrated. Skipping the Alembic check avoids redundant engine + # creation, SQLite lock contention, and the cumulative overhead that + # causes intermittent hangs in parallel test runs. if db_path.exists() and db_path.stat().st_size > 0: - return _original_init_or_upgrade(self, **kwargs) + return # Copy the template — creates a fully-migrated DB in ~1ms db_path.parent.mkdir(parents=True, exist_ok=True)