hussein-awala commented on code in PR #38876:
URL: https://github.com/apache/airflow/pull/38876#discussion_r1569650413


##########
airflow/utils/db.py:
##########
@@ -1666,11 +1667,14 @@ def upgradedb(
         _reserialize_dags(session=session)
     add_default_pool_if_not_exists(session=session)
     synchronize_log_template(session=session)
-    if _revision_greater(
-        config,
-        _REVISION_HEADS_MAP["2.9.0"],
-        _get_current_revision(session=session),
+    current_version = _get_current_revision(session=session)

Review Comment:
   ```suggestion
       current_version = _from_revision
   ```



##########
tests/utils/test_db.py:
##########
@@ -143,23 +143,29 @@ def test_offline_upgrade_wrong_order(self, from_revision, 
to_revision):
         ],
     )
     def test_offline_upgrade_revision_nothing(self, from_revision, 
to_revision):
-        with mock.patch("airflow.utils.db.settings.engine.dialect"):
-            with mock.patch("alembic.command.upgrade"):
-                with redirect_stdout(StringIO()) as temp_stdout:
-                    upgradedb(to_revision=to_revision, 
from_revision=from_revision, show_sql_only=True)
-                stdout = temp_stdout.getvalue()
-                assert "nothing to do" in stdout
-
+        with mock.patch("alembic.command.upgrade"):
+            with redirect_stdout(StringIO()) as temp_stdout:
+                upgradedb(to_revision=to_revision, 
from_revision=from_revision, show_sql_only=True)
+            stdout = temp_stdout.getvalue()
+            assert "nothing to do" in stdout
+
+    @pytest.mark.skipif(
+        conf.get_mandatory_value("database", 
"sql_alchemy_conn").lower().startswith("sqlite"),
+        reason="Offline migration not supported for SQLite.",
+    )
     @pytest.mark.parametrize(
         "from_revision, to_revision",
         [("90d1635d7b86", "54bebd308c5f"), ("e959f08ac86c", "587bdf053233")],
     )
     def test_offline_upgrade_revision(self, from_revision, to_revision):
-        with mock.patch("airflow.utils.db.settings.engine.dialect"):
-            with mock.patch("alembic.command.upgrade") as mock_alembic_upgrade:
-                upgradedb(from_revision=from_revision, 
to_revision=to_revision, show_sql_only=True)
+        with mock.patch("alembic.command.upgrade") as mock_alembic_upgrade:
+            upgradedb(from_revision=from_revision, to_revision=to_revision, 
show_sql_only=True)
         mock_alembic_upgrade.assert_called_once_with(mock.ANY, 
f"{from_revision}:{to_revision}", sql=True)
 
+    @pytest.mark.skipif(
+        conf.get_mandatory_value("database", 
"sql_alchemy_conn").lower().startswith("sqlite"),
+        reason="Offline migration not supported for SQLite.",

Review Comment:
   The tests are not valid for `SQLite` , they should be skipped because of 
https://github.com/apache/airflow/blob/1769ed0b65cae00005e7c8b373cbb941eecd051e/airflow/utils/db.py#L1563
   But before `_get_current_revision` was not used if `show_sql_only=True`.
   
   I can refactor it if needed to revert the tests



##########
airflow/utils/db.py:
##########
@@ -1666,11 +1667,14 @@ def upgradedb(
         _reserialize_dags(session=session)
     add_default_pool_if_not_exists(session=session)
     synchronize_log_template(session=session)
-    if _revision_greater(
-        config,
-        _REVISION_HEADS_MAP["2.9.0"],
-        _get_current_revision(session=session),
+    current_version = _get_current_revision(session=session)
+    trigger_kwargs_encryption_version = _REVISION_HEADS_MAP["2.9.0"]
+    if (
+        _from_revision != trigger_kwargs_encryption_version
+        and _revision_greater(config, trigger_kwargs_encryption_version, 
_from_revision)
+        and _revision_greater(config, current_version, 
trigger_kwargs_encryption_version)

Review Comment:
   ```suggestion
       if (
           _from_revision != trigger_kwargs_encryption_revision
           and _revision_greater(config, trigger_kwargs_encryption_revision, 
_from_revision)
           and _revision_greater(config, current_version, 
trigger_kwargs_encryption_revision)
   ```



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

Reply via email to