amoghrajesh commented on code in PR #65759: URL: https://github.com/apache/airflow/pull/65759#discussion_r3154080748
########## airflow-core/src/airflow/migrations/versions/0112_3_3_0_add_task_state_and_asset_state_tables.py: ########## @@ -0,0 +1,84 @@ +# +# 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. + +""" +Add task_state and asset_state tables. + +Revision ID: fde9ed84d07b +Revises: 9fabad868fdb +Create Date: 2026-04-27 09:29:20.165461 + +""" + +from __future__ import annotations + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import mysql + +from airflow.utils.sqlalchemy import UtcDateTime + +# revision identifiers, used by Alembic. +revision = "fde9ed84d07b" +down_revision = "9fabad868fdb" +branch_labels = None +depends_on = None +airflow_version = "3.3.0" + + +def upgrade(): + """Apply add task_state and asset_state tables.""" + op.create_table( + "asset_state", + sa.Column("asset_id", sa.Integer(), nullable=False), + sa.Column("key", sa.String(length=512), nullable=False), + sa.Column("value", sa.Text().with_variant(mysql.MEDIUMTEXT(), "mysql"), nullable=False), + sa.Column("updated_at", UtcDateTime(), nullable=False), + sa.ForeignKeyConstraint( + ["asset_id"], ["asset.id"], name="asset_state_asset_fkey", ondelete="CASCADE" + ), + sa.PrimaryKeyConstraint("asset_id", "key", name="asset_state_pkey"), + ) + op.create_table( + "task_state", + sa.Column("dag_run_id", sa.Integer(), nullable=False), + sa.Column("task_id", sa.String(length=250), nullable=False), Review Comment: Good catch. Switched both the migration `(task_id, dag_id, run_id columns in task_state)` and the ORM model to use `StringID(), same pattern as migration number: 0108. -- 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]
