Skip to content

Commit f5f7c1a

Browse files
Reloading yoyo migrations
1 parent 74d01d8 commit f5f7c1a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/db_schema_migrations/yoyo_migration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import structlog
44
import yoyo
55

6+
from app.config import settings
67

7-
def apply_db_migrations(mode: str = "apply"):
8-
from app.config import settings
98

9+
def apply_db_migrations(mode: str = "apply"):
1010
logger = structlog.get_logger()
1111
logger.info(f"Running Yoyo Migrations: {mode.upper()}")
1212

tests_integration/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import app.config as config
1212
import app.main as main
13+
import app.db_schema_migrations.yoyo_migration as yoyo_migration
1314

1415

1516
@pytest.fixture(scope="session")
@@ -45,7 +46,9 @@ def change_posgtres_db_host(
4546
original_value = os.getenv(name)
4647
new_value = postgres_docker_container.get_container_host_ip()
4748
# set new value, reload module and yield setting
48-
yield patch_env_var(monkeypatch, name, new_value)
49+
new_settings = patch_env_var(monkeypatch, name, new_value)
50+
reload(yoyo_migration)
51+
yield new_settings
4952
# reset to original value and reload module
5053
patch_env_var(monkeypatch, name, original_value)
5154

@@ -58,7 +61,9 @@ def change_posgtres_db_port(
5861
original_value = os.getenv(name)
5962
new_value = str(postgres_docker_container.get_exposed_port(5432))
6063
# set new value, reload module and yield setting
61-
yield patch_env_var(monkeypatch, name, new_value)
64+
new_settings = patch_env_var(monkeypatch, name, new_value)
65+
reload(yoyo_migration)
66+
yield new_settings
6267
# reset to original value and reload module
6368
patch_env_var(monkeypatch, name, original_value)
6469

0 commit comments

Comments
 (0)