ephraimbuddy commented on a change in pull request #20962:
URL: https://github.com/apache/airflow/pull/20962#discussion_r806756536
##########
File path: airflow/cli/cli_parser.py
##########
@@ -224,6 +224,16 @@ def _check(value):
default=ColorMode.AUTO,
)
+# DB args
+ARG_VERSION_RANGE = Arg(
+ ("-v", "--version-range"), help="Version range(start:end) for offline sql
generation", default=None
Review comment:
Should we use `-vr` here instead? since this is also about versions so
that it doesn't confuse with revision-range?
##########
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:
The message gives the impression of generating a migration script but
there's no script at all for the user. It's a message to tell the user that
there's no migration. I think it's Ok like this?
--
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]