Skip to content

Commit

Permalink
Delete the Serialized Dag and DagCode before DagVersion migration
Browse files Browse the repository at this point in the history
This is necessary for a smooth migration from the old DB to the new
one that added versioning; otherwise, the non-nullable columns raise an integrity error.

Instead of populating those not nullable columns, this seems to be
a better option since the Serialized Dag and DagCode would be regenerated after the migration.
  • Loading branch information
ephraimbuddy committed Nov 5, 2024
1 parent f2dd350 commit a409ce9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@
airflow_version = "3.0.0"


def _delete_serdag_and_code():
op.execute(sa.text("DELETE FROM serialized_dag"))
op.execute(sa.text("DELETE FROM dag_code"))


def upgrade():
"""Apply add dag versioning."""
# Before creating the dag_version table, we need to delete the existing serialized_dag and dag_code tables
_delete_serdag_and_code()
op.create_table(
"dag_version",
sa.Column("id", UUIDType(binary=False), nullable=False),
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 @@
f997746cdee45147831f81bcd2d43ec3ca45d7429afa691e385104987ed51d88
4adae6a26c3378a5da5468eecfcbd27948c2af285a8dcf12ff8c3969e19f19f7

0 comments on commit a409ce9

Please sign in to comment.