You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/17 10:24:38 UTC
[GitHub] [airflow] bhavaniravi commented on issue #18323: Detect and fail any command when db is not migrated
bhavaniravi commented on issue #18323:
URL: https://github.com/apache/airflow/issues/18323#issuecomment-921686654
Yes, it's possible in the alembic. [Check this SO answer](https://stackoverflow.com/a/56085521/6340775)
A similar airflow snippet would look like, used `check_migrations` as a template
```
def compare_migrations():
from alembic.runtime.migration import MigrationContext
from alembic.script import ScriptDirectory
config = _get_alembic_config()
script_ = ScriptDirectory.from_config(config)
with settings.engine.connect() as connection:
context = MigrationContext.configure(connection)
if context.get_current_revision() != script_.get_current_head():
raise exceptions.DatabaseIsNotUpToDate('Upgrade the database.')
```
Do we do this check every time we start the webserver or scheduler?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org