This is an automated email from the ASF dual-hosted git repository.
kaxil 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 c1056986fff Fix missing autoincrement sequence on callback_request
downgrade (#65230)
c1056986fff is described below
commit c1056986fff15b629829962b8a810d6f505fbdb2
Author: rjgoyln <[email protected]>
AuthorDate: Fri May 1 06:49:25 2026 +0800
Fix missing autoincrement sequence on callback_request downgrade (#65230)
closes: #65000
---
.../0093_3_2_0_restructure_callback_table.py | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git
a/airflow-core/src/airflow/migrations/versions/0093_3_2_0_restructure_callback_table.py
b/airflow-core/src/airflow/migrations/versions/0093_3_2_0_restructure_callback_table.py
index d7037393ce6..640ff5728af 100644
---
a/airflow-core/src/airflow/migrations/versions/0093_3_2_0_restructure_callback_table.py
+++
b/airflow-core/src/airflow/migrations/versions/0093_3_2_0_restructure_callback_table.py
@@ -96,3 +96,34 @@ def downgrade():
batch_op.drop_column("type")
op.rename_table("callback", "callback_request")
+ bind = op.get_bind()
+ dialect_name = bind.dialect.name
+ if dialect_name == "postgresql":
+ op.execute("CREATE SEQUENCE IF NOT EXISTS callback_request_id_seq")
+
+ with op.batch_alter_table("callback_request", schema=None) as batch_op:
+ batch_op.alter_column(
+ "id",
+ existing_type=sa.INTEGER(),
+ nullable=False,
+ server_default=sa.text("nextval('callback_request_id_seq')"),
+ )
+
+ op.execute("ALTER SEQUENCE callback_request_id_seq OWNED BY
callback_request.id")
+ op.execute(
+ "SELECT setval('callback_request_id_seq', "
+ "COALESCE((SELECT MAX(id) FROM callback_request), 1), "
+ "(SELECT MAX(id) IS NOT NULL FROM callback_request))"
+ )
+
+ elif dialect_name == "mysql":
+ with op.batch_alter_table("callback_request", schema=None) as batch_op:
+ batch_op.alter_column(
+ "id",
+ existing_type=sa.INTEGER(),
+ nullable=False,
+ autoincrement=True,
+ )
+ result = bind.execute(sa.text("SELECT COALESCE(MAX(id), 0) + 1 FROM
callback_request"))
+ next_id = result.scalar()
+ op.execute(sa.text(f"ALTER TABLE callback_request AUTO_INCREMENT =
{next_id}"))