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


##########
airflow/migrations/versions/0140_2_9_0_update_trigger_kwargs_type.py:
##########
@@ -0,0 +1,56 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""update trigger kwargs type
+
+Revision ID: 1949afb29106
+Revises: ee1467d4aa35
+Create Date: 2024-03-17 22:09:09.406395
+
+"""
+import sqlalchemy as sa
+
+from airflow.models.trigger import Trigger
+from alembic import op
+
+from airflow.utils.sqlalchemy import ExtendedJSON
+
+# revision identifiers, used by Alembic.
+revision = "1949afb29106"
+down_revision = "ee1467d4aa35"
+branch_labels = None
+depends_on = None
+airflow_version = "2.9.0"
+
+
+def get_session() -> sa.orm.Session:
+    conn = op.get_bind()
+    sessionmaker = sa.orm.sessionmaker()
+    return sessionmaker(bind=conn)
+
+
+def upgrade():
+    """Update trigger kwargs type to string"""
+    op.alter_column(table_name="trigger", column_name="kwargs", 
type_=sa.Text())
+
+
+def downgrade():
+    """Unapply update trigger kwargs type to string"""
+    op.alter_column(
+        table_name="trigger", column_name="kwargs", type_=ExtendedJSON(), 
postgresql_using="kwargs::json"
+    )

Review Comment:
   I had to keep `postgresql_using="kwargs::json"` to fix this error:
   ```
   sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) column 
"kwargs" cannot be cast automatically to type json
   HINT:  You might need to specify "USING kwargs::json".
   
   [SQL: ALTER TABLE trigger ALTER COLUMN kwargs TYPE JSON ]
   (Background on this error at: https://sqlalche.me/e/14/f405)
   ```



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to