Skip to content

Commit

Permalink
Change table Xcom value column value type to longblob from blob
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed Mar 22, 2024
1 parent a1671f1 commit 31998f6
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# 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.

"""Change value column type to longblob in xcom table for mysql
Revision ID: b4078ac230a1
Revises: 8e1c784a4fc7
Create Date: 2024-03-22 14:06:51.185268
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects.mysql import LONGBLOB

# revision identifiers, used by Alembic.
revision = 'b4078ac230a1'
down_revision = '8e1c784a4fc7'
branch_labels = None
depends_on = None
airflow_version = '2.9.0'


def upgrade():
"""Apply Change value column type to longblob in xcom table for mysql"""
conn = op.get_bind()
if conn.dialect.name == "mssql":
with op.batch_alter_table("xcom", schema=None) as batch_op:
batch_op.alter_column("value", type_=sa.LargeBinary().with_variant(LONGBLOB, "mysql"))


def downgrade():
"""Unapply Change value column type to longblob in xcom table for mysql"""
conn = op.get_bind()
if conn.dialect.name == "mssql":
with op.batch_alter_table("xcom", schema=None) as batch_op:
batch_op.alter_column("value", type_=sa.LargeBinary)
3 changes: 2 additions & 1 deletion airflow/models/xcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
delete,
text,
)
from sqlalchemy.dialects.mysql import LONGBLOB
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import Query, reconstructor, relationship
from sqlalchemy.orm.exc import NoResultFound
Expand Down Expand Up @@ -89,7 +90,7 @@ class BaseXCom(TaskInstanceDependencies, LoggingMixin):
dag_id = Column(String(ID_LEN, **COLLATION_ARGS), nullable=False)
run_id = Column(String(ID_LEN, **COLLATION_ARGS), nullable=False)

value = Column(LargeBinary)
value = Column(LargeBinary().with_variant(LONGBLOB, "mysql"))
timestamp = Column(UtcDateTime, default=timezone.utcnow, nullable=False)

__table_args__ = (
Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ce71fa2d8f6daea541c46d3528961bdee87421b3612ed2f2451e88630a52fd70
1ee8b81213db8924941ac057f9ff976f738c80fe87969e9335c9328d030f2195
68 changes: 34 additions & 34 deletions docs/apache-airflow/img/airflow_erd.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/apache-airflow/migrations-ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Here's the list of all the Database Migrations that are executed via when you ru
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
| Revision ID | Revises ID | Airflow Version | Description |
+=================================+===================+===================+==============================================================+
| ``8e1c784a4fc7`` (head) | ``ab34f260b71c`` | ``2.9.0`` | Adding max_consecutive_failed_dag_runs column to dag_model |
| ``b4078ac230a1`` (head) | ``8e1c784a4fc7`` | ``2.9.0`` | Change value column type to longblob in xcom table for mysql |
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
| ``8e1c784a4fc7`` | ``ab34f260b71c`` | ``2.9.0`` | Adding max_consecutive_failed_dag_runs column to dag_model |
| | | | table |
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
| ``ab34f260b71c`` | ``d75389605139`` | ``2.9.0`` | add dataset_expression in DagModel |
Expand Down

0 comments on commit 31998f6

Please sign in to comment.