Skip to content

Fix: Restore task_instance_history sequence on downgrade#61976

Open
vatsrahul1001 wants to merge 1 commit intoapache:mainfrom
astronomer:fix-tih-seq
Open

Fix: Restore task_instance_history sequence on downgrade#61976
vatsrahul1001 wants to merge 1 commit intoapache:mainfrom
astronomer:fix-tih-seq

Conversation

@vatsrahul1001
Copy link
Contributor

@vatsrahul1001 vatsrahul1001 commented Feb 16, 2026

During a rollback from Airflow 3 to Airflow 2, the task_instance_history_id_seq PostgreSQL sequence was not being recreated. This caused task_instance_history inserts to fail with NULL constraint violations since the id column had no DEFAULT value for auto-increment.

Root Cause

In the upgrade path (migration 0060), the id column is dropped:
batch_op.drop_column("id")When PostgreSQL drops a column with an associated sequence, the sequence is also dropped (due to ownership).

Testing

  1. Run command breeze start-airflow --executor CeleryExecutor --backend postgres
  2. Down try downgarding airflow db downgrade --to-revision e00344393f31 -y
  3. Verify Seq is getting created after downgrade
image
  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@vatsrahul1001 vatsrahul1001 added backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch and removed kind:documentation labels Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:db-migrations PRs with DB migration backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant