This is an automated email from the ASF dual-hosted git repository.
weilee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new c74ecd4f6a5 fix(migrations): only ignore value error when interacting
with constraints in sqlite (#51529)
c74ecd4f6a5 is described below
commit c74ecd4f6a5f9d39a42b554539b5e0b66d005692
Author: Wei Lee <[email protected]>
AuthorDate: Wed Jun 11 16:06:31 2025 +0800
fix(migrations): only ignore value error when interacting with constraints
in sqlite (#51529)
The original syntax will ignore the whole batch if a ValueError is
encountered. The migration process will work, but wrongly.
In this example, dag_run.created_at will not be created for SQLite, which
will cause an error when running Airflow.
---
airflow-core/docs/img/airflow_erd.sha256 | 2 +-
.../src/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/airflow-core/docs/img/airflow_erd.sha256
b/airflow-core/docs/img/airflow_erd.sha256
index 51c2117fd5b..b5e4372a352 100644
--- a/airflow-core/docs/img/airflow_erd.sha256
+++ b/airflow-core/docs/img/airflow_erd.sha256
@@ -1 +1 @@
-173317aa67c36d8a257bc31c99eeedf906390cebdd9c6941d6e9c3db0515d5c5
\ No newline at end of file
+71743446a269a520d2a6a9511eff99d7fc8c4b0409ba58b4bc3b2e1fee195774
\ No newline at end of file
diff --git
a/airflow-core/src/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
b/airflow-core/src/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
index e411c8f43c8..2cad82e1e7f 100644
---
a/airflow-core/src/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
+++
b/airflow-core/src/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
@@ -71,8 +71,11 @@ def upgrade():
sa.PrimaryKeyConstraint("id", name=op.f("dag_version_pkey")),
sa.UniqueConstraint("dag_id", "version_number",
name="dag_id_v_name_v_number_unique_constraint"),
)
+
with ignore_sqlite_value_error(), op.batch_alter_table("dag_code") as
batch_op:
batch_op.drop_constraint("dag_code_pkey", type_="primary")
+
+ with op.batch_alter_table("dag_code") as batch_op:
batch_op.drop_column("fileloc_hash")
batch_op.add_column(sa.Column("id", UUIDType(binary=False),
nullable=False))
batch_op.create_primary_key("dag_code_pkey", ["id"])
@@ -91,6 +94,8 @@ def upgrade():
with ignore_sqlite_value_error(), op.batch_alter_table("serialized_dag")
as batch_op:
batch_op.drop_constraint("serialized_dag_pkey", type_="primary")
+
+ with op.batch_alter_table("serialized_dag") as batch_op:
batch_op.drop_index("idx_fileloc_hash")
batch_op.drop_column("fileloc_hash")
batch_op.drop_column("fileloc")