ashb commented on a change in pull request #20962:
URL: https://github.com/apache/airflow/pull/20962#discussion_r806708729
##########
File path: airflow/utils/db.py
##########
@@ -989,8 +1005,93 @@ def _check_migration_errors(session: Session =
NEW_SESSION) -> Iterable[str]:
session.commit()
+def _offline_migration(command, config, revision):
+ log.info("Running offline migrations for revision range %s", revision)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ logging.disable(logging.CRITICAL)
+ command.upgrade(config, revision, sql=True)
+ logging.disable(logging.NOTSET)
+
+
+def _validate_version_range(command, config, version_range):
+ if ':' not in version_range:
+ raise AirflowException(
+ 'Please provide Airflow version range with the format
"old_version:new_version"'
+ )
+ lower, upper = version_range.split(':')
+
+ if not REVISION_HEADS_MAP.get(lower) or not REVISION_HEADS_MAP.get(upper):
+ raise AirflowException('Please provide valid Airflow versions above
2.0.0.')
+ if REVISION_HEADS_MAP.get(lower) == REVISION_HEADS_MAP.get(upper):
+ if sys.stdout.isatty():
+ size = os.get_terminal_size().columns
+ else:
+ size = 0
+ print(f"Hey this is your migration script from {lower}, to {upper},
but guess what?".center(size))
Review comment:
Should we prefix all these messages with `--` to make them SQL comments?
--
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]