zach-overflow commented on code in PR #59239:
URL: https://github.com/apache/airflow/pull/59239#discussion_r2645735300


##########
airflow-core/src/airflow/migrations/versions/0015_2_9_0_update_trigger_kwargs_type.py:
##########
@@ -55,16 +51,9 @@ def get_session() -> sa.orm.Session:
 def upgrade():
     """Update trigger kwargs type to string and encrypt."""
     with op.batch_alter_table("trigger") as batch_op:
-        batch_op.alter_column("kwargs", type_=sa.Text(), 
existing_nullable=False)
-
-    if not context.is_offline_mode():
-        session = get_session()
-        try:
-            for trigger in 
session.query(Trigger).options(lazyload(Trigger.task_instance)):
-                trigger.kwargs = trigger.kwargs
-            session.commit()
-        finally:
-            session.close()
+        batch_op.alter_column(
+            "kwargs", existing_type=ExtendedJSON(), type_=sa.Text(), 
existing_nullable=False
+        )

Review Comment:
   I agree that it is not ideal to be modifying a pre-existing migration 
script, but I'm not sure about an ambiguity here: I found that prior to this 
change the downgrade migrations would fail because the `Trigger` ORM was 
directly referenced, including its `trigger_queue` column, leading to a "column 
does not exist" [failure on the downgrade 
here](https://github.com/apache/airflow/pull/59239#discussion_r2637195396). I 
didn't see any other past migration scripts which referenced an ORM class 
directly, but I can see if the proposed route works even when the `Trigger` 
class is still present in this old migration script.



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