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 2022/01/25 23:03:30 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #20962: Support generating SQL script for upgrades

ephraimbuddy commented on a change in pull request #20962:
URL: https://github.com/apache/airflow/pull/20962#discussion_r792194993



##########
File path: airflow/utils/db.py
##########
@@ -1018,8 +1018,18 @@ 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'
+        _lowerband = revision.split(':')[0] if ":" in revision else None
+        if _lowerband and _lowerband != rev_2_0_0_head:
+            sql = True  # Set to true if user passes a range of revisions
+            try:
+                command.history(config, rev_range=f"{rev_2_0_0_head}:{_lowerband}")
+            except Exception:
+                raise AirflowException(
+                    f"Supported revision is from {rev_2_0_0_head} which is airflow 2.0.0 head"
+                )

Review comment:
       It will work. It will first check if we can get history from 2.0.0 to 2.2.0 which will succeed, then it means the range is correct and upgrade command can run




-- 
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