Skip to content

Commit a409ce9

Browse files
committed
Delete the Serialized Dag and DagCode before DagVersion migration
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.
1 parent f2dd350 commit a409ce9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

airflow/migrations/versions/0047_3_0_0_add_dag_versioning.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@
4444
airflow_version = "3.0.0"
4545

4646

47+
def _delete_serdag_and_code():
48+
op.execute(sa.text("DELETE FROM serialized_dag"))
49+
op.execute(sa.text("DELETE FROM dag_code"))
50+
51+
4752
def upgrade():
4853
"""Apply add dag versioning."""
54+
# Before creating the dag_version table, we need to delete the existing serialized_dag and dag_code tables
55+
_delete_serdag_and_code()
4956
op.create_table(
5057
"dag_version",
5158
sa.Column("id", UUIDType(binary=False), nullable=False),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f997746cdee45147831f81bcd2d43ec3ca45d7429afa691e385104987ed51d88
1+
4adae6a26c3378a5da5468eecfcbd27948c2af285a8dcf12ff8c3969e19f19f7

0 commit comments

Comments
 (0)