Skip to content

Commit

Permalink
Always run migrations on pg_maindb_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jotare committed Jul 26, 2024
1 parent 49304c2 commit 723192e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nucliadb/tests/ndbfixtures/maindb.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,21 @@ async def maindb_driver(request: FixtureRequest) -> AsyncIterator[Driver]:
async def pg_maindb_settings(pg):
url = f"postgresql://postgres:postgres@{pg[0]}:{pg[1]}/postgres"

# We want to be sure schema migrations are always run. As some tests use
# this fixture and create their own driver, we need to create one here and
# run the migrations, so the maindb_settings fixture can still be generic
# and pg migrations are run
driver = PGDriver(url=url, connection_pool_min_size=2, connection_pool_max_size=2)
await driver.initialize()
await run_pg_schema_migrations(driver)
await driver.finalize()

yield DriverSettings(
driver=DriverConfig.PG,
driver_pg_url=url,
driver_pg_connection_pool_min_size=2,
driver_pg_connection_pool_max_size=2,
driver_pg_connection_pool_min_size=10,
driver_pg_connection_pool_max_size=10,
driver_pg_connection_pool_acquire_timeout_ms=200,
)


Expand All @@ -131,6 +141,7 @@ async def pg_maindb_driver(pg_maindb_settings: DriverSettings):
url=url,
connection_pool_min_size=pg_maindb_settings.driver_pg_connection_pool_min_size,
connection_pool_max_size=pg_maindb_settings.driver_pg_connection_pool_max_size,
acquire_timeout_ms=pg_maindb_settings.driver_pg_connection_pool_acquire_timeout_ms,
)
await driver.initialize()
await run_pg_schema_migrations(driver)
Expand Down

0 comments on commit 723192e

Please sign in to comment.