ashb commented on a change in pull request #19597:
URL: https://github.com/apache/airflow/pull/19597#discussion_r750124443
##########
File path: airflow/utils/db.py
##########
@@ -627,27 +627,32 @@ def check_migrations(timeout):
:param timeout: Timeout for the migration in seconds
:return: None
"""
- from alembic.runtime.migration import MigrationContext
+ from alembic.runtime.environment import EnvironmentContext
from alembic.script import ScriptDirectory
config = _get_alembic_config()
script_ = ScriptDirectory.from_config(config)
- with settings.engine.connect() as connection:
- context = MigrationContext.configure(connection)
- ticker = 0
- while True:
- source_heads = set(script_.get_heads())
- db_heads = set(context.get_current_heads())
- if source_heads == db_heads:
- break
- if ticker >= timeout:
- raise TimeoutError(
- f"There are still unapplied migrations after {ticker}
seconds. "
- f"Migration Head(s) in DB: {db_heads} | Migration Head(s)
in Source Code: {source_heads}"
- )
- ticker += 1
- time.sleep(1)
- log.info('Waiting for migrations... %s second(s)', ticker)
+ with EnvironmentContext(
+ config,
+ script_,
+ ) as env:
+ with settings.engine.connect() as connection:
Review comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]