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


##########
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:
   So after some more digging, I don't see a way to avoid modifying this prior 
migration script since my change already does add a new migration script for 
the addition of the `queue` column on upgrade / removal of the `queue` column 
on downgrade. That doesn't mitigate the problematic usage of the ORM class in 
the old migration script (which will have column attributes that are no longer 
present). I believe the reference to the `Trigger` sqlalchemy class in this 
migration script is the root problem, if I'm understanding [this SO 
thread](https://stackoverflow.com/questions/13676744/using-the-sqlalchemy-orm-inside-an-alembic-migration-how-do-i#comment64254760_36087108),
 and a relevant [discussion in this past 
PR](https://github.com/apache/airflow/pull/38743).
   
   I definitely agree it is not ideal to modify a prior migration script, but 
I'm not sure of an alternative. Please let me know if there is something I'm 
not understanding though!



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