This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi 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 9fedfd5e390 Delete `dag_version` table when downgrading the DB from
the versioned Airflow (#44397)
9fedfd5e390 is described below
commit 9fedfd5e390c47d45193caf20944be45d33f031d
Author: Ephraim Anierobi <[email protected]>
AuthorDate: Wed Nov 27 07:47:23 2024 +0100
Delete `dag_version` table when downgrading the DB from the versioned
Airflow (#44397)
In dagcode, fileloc_hash column was a primary key on the version before dag
versioning. If dagcode is not deleted before downgrading, the fileloc_hash
column,
created when downgrading, would be a null column that can't be used for a
primary key.
A similar thing applies to serialized dag, which would have duplicates, and
the
primary key can't be determined. The solution is to delete the dag_version
table data,
which will delete the serdag and dagcode table data
---
airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py | 3 +++
docs/apache-airflow/img/airflow_erd.sha256 | 2 +-
docs/apache-airflow/img/airflow_erd.svg | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
b/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
index 5b4bc169751..35234894367 100644
--- a/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
+++ b/airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
@@ -132,6 +132,9 @@ def upgrade():
def downgrade():
"""Unapply add dag versioning."""
+ # Going down from here, the way we serialize DAG changes, so we need to
delete the dag_version table
+ # which in turn deletes the serialized dag and dag code tables.
+ op.execute(sa.text("DELETE FROM dag_version"))
with op.batch_alter_table("task_instance_history", schema=None) as
batch_op:
batch_op.drop_column("dag_version_id")
diff --git a/docs/apache-airflow/img/airflow_erd.sha256
b/docs/apache-airflow/img/airflow_erd.sha256
index df1987158fc..6b004f91298 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-5042271e47bcf1160477200adae4c42ce1cecacf5cbbe7e334d6268debe857fb
\ No newline at end of file
+aa9e2e5b2a52af1e92bc876727ad5e8958e291315096fc5249a9afa2c21a5d06
\ No newline at end of file
diff --git a/docs/apache-airflow/img/airflow_erd.svg
b/docs/apache-airflow/img/airflow_erd.svg
index 5073c4f273e..fd06e1810f7 100644
--- a/docs/apache-airflow/img/airflow_erd.svg
+++ b/docs/apache-airflow/img/airflow_erd.svg
@@ -1119,7 +1119,7 @@
<polygon fill="none" stroke="black" points="1776,-1847 1776,-1872 2038,-1872
2038,-1847 1776,-1847"/>
<text text-anchor="start" x="1781" y="-1856.8"
font-family="Helvetica,sans-Serif" font-size="14.00">value</text>
<text text-anchor="start" x="1819" y="-1856.8"
font-family="Helvetica,sans-Serif" font-size="14.00"> </text>
-<text text-anchor="start" x="1824" y="-1856.8"
font-family="Helvetica,sans-Serif" font-size="14.00"> [JSON]</text>
+<text text-anchor="start" x="1824" y="-1856.8"
font-family="Helvetica,sans-Serif" font-size="14.00"> [JSONB]</text>
</g>
<!-- task_instance--xcom -->
<g id="edge49" class="edge">