From e01421bb960d7b420bc26781419148828088d157 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Mon, 30 Nov 2026 10:54:22 +0100 Subject: [PATCH] Close the connection after running the migrations The pooled `connection` stayed open until garbage collection, which emits a `ResourceWarning` --- migrations/env.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migrations/env.py b/migrations/env.py index 5b090b4..49d1ac8 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -31,7 +31,8 @@ def include_object(obj, _name, type_, _reflected, _compare_to): return True -engine = sa.create_engine(velofy_config.DATABASE_URI) +# Without a `pool`, the `connection` really closes after the migrations +engine = sa.create_engine(velofy_config.DATABASE_URI, poolclass=sa.pool.NullPool) test_schema = f"_{velofy_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""