ashb commented on a change in pull request #20962:
URL: https://github.com/apache/airflow/pull/20962#discussion_r793756208
##########
File path: airflow/utils/db.py
##########
@@ -1018,8 +1018,42 @@ def upgradedb(session: Session = NEW_SESSION):
exit(1)
with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):
- log.info("Creating tables")
- command.upgrade(config, 'heads')
+ log.info("Running migrations")
+ rev_2_0_0_head = 'e959f08ac86c'
+ if ':' in revision:
+ sql = True
+ _lowerband, _upperband = revision.split(':')
+ head_to_lowerband_range = f"{rev_2_0_0_head}:{_lowerband}"
+ head_to_upperband_range = f"{rev_2_0_0_head}:{_upperband}"
+ for i in [head_to_lowerband_range, head_to_upperband_range]:
+ try:
+ command.history(config, rev_range=i)
+ except Exception:
+ raise AirflowException(
+ f"Error while checking history for revision range {i}.
"
+ f"Check that {i.split(':')[1]} is a valid revision. "
+ f"Supported revision for offline migration is from
{rev_2_0_0_head} "
+ f"which is airflow 2.0.0 head"
+ )
+ log.info("Running offline migrations for revision range %s",
revision)
+ elif sql:
+ # user supplied a specific SQL revision
+ revision = f"{rev_2_0_0_head}:{revision}"
+ try:
+ command.history(config, rev_range=revision)
Review comment:
Doesn't this produce output? Is that intended?
--
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]