Skip to content

Re-introducing --use-migration-files and fix inconsistences between ORM/migration files#62234

Merged
ephraimbuddy merged 11 commits intoapache:mainfrom
astronomer:re-introduce-use-migration-files
Mar 17, 2026
Merged

Re-introducing --use-migration-files and fix inconsistences between ORM/migration files#62234
ephraimbuddy merged 11 commits intoapache:mainfrom
astronomer:re-introduce-use-migration-files

Conversation

@ephraimbuddy
Copy link
Copy Markdown
Contributor

The --use-migration-files flag was removed in #41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema.

Now that we have a squashed migration (0000_2_6_2) with down_revision = None that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using alembic revision --autogenerate to detect schema drift between the ORM models and the migration-produced schema. Without this flag, autogenerate compares against an ORM-created database (via create_all), which masks any drift since both sides come from the same ORM definitions.

@ephraimbuddy ephraimbuddy force-pushed the re-introduce-use-migration-files branch 2 times, most recently from 1f0e30a to 4637686 Compare February 26, 2026 10:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.

Copy link
Copy Markdown
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — previous comments addressed. Two minor items on the new migration code.

@ephraimbuddy ephraimbuddy force-pushed the re-introduce-use-migration-files branch 3 times, most recently from 4f5ccb1 to e5b0512 Compare March 17, 2026 07:26
… ORM/migration files

The `--use-migration-files` flag was removed in apache#41120 when we pruned the
migration history for Airflow 3. At the time, we couldn't create a database
from scratch using only migration files because the migration chain no
longer started from an empty database. The oldest migration assumed an
existing 2.6.2 schema.

Now that we have a squashed migration (0000_2_6_2) with
`down_revision = None` that creates the full baseline schema from scratch,
we can re-introduce this flag. This enables a critical development
workflow, which is: creating the database purely from migration files, then using
`alembic revision --autogenerate` to detect schema drift between the ORM
models and the migration-produced schema. Without this flag, `autogenerate`
compares against an ORM-created database (via `create_all`), which masks
any drift since both sides come from the same ORM definitions.
@ephraimbuddy ephraimbuddy force-pushed the re-introduce-use-migration-files branch from e5b0512 to 49f15fd Compare March 17, 2026 13:40
@ephraimbuddy ephraimbuddy merged commit 03c6388 into apache:main Mar 17, 2026
134 checks passed
@ephraimbuddy ephraimbuddy deleted the re-introduce-use-migration-files branch March 17, 2026 15:52
@github-actions
Copy link
Copy Markdown

Backport failed to create: v3-1-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 03c6388 v3-1-test

This should apply the commit to the v3-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Mar 18, 2026
migration 0108 in PR apache#62234 to backfill existing NULLs. After revisiting the change,
we found the migration was correcting nullability drift introduced by
that PR itself, and that the PR has not been released yet.

Instead of shipping a large corrective migration, remove 0108 and restore
the affected ORM fields to nullable so the models stay aligned with the
actual schema and previous releases behavior.

Also optimize migration 0094 by keeping the callback data migration
correct while reducing repeated scans during batching.
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Mar 18, 2026
PR apache#56330 mistakenly changed several ORM-backed columns from nullable to
non-nullable. I later added a corrective migration in PR apache#62234 to
backfill existing NULLs, but after revisiting the issue we found the
migration was only compensating for the nullability mistake introduced by
PR apache#56330 itself, which has not been released.

Instead of shipping a large corrective migration for an unreleased
regression, delete the migration file and restore the affected ORM fields
to nullable so the models stay aligned with the actual schema and
intended pre-release behavior.
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Mar 18, 2026
PR apache#56330 mistakenly changed several ORM-backed columns from nullable to
non-nullable. I later added a corrective migration in PR apache#62234 to
backfill existing NULLs, but after revisiting the issue we found the
migration was only compensating for the nullability mistake introduced by
PR apache#56330 itself, which has not been released.

Instead of shipping a large corrective migration for an unreleased
regression, delete the migration file and restore the affected ORM fields
to nullable so the models stay aligned with the actual schema and
intended pre-release behavior.
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Mar 19, 2026
PR apache#56330 mistakenly changed several ORM-backed columns from nullable to
non-nullable. I later added a corrective migration in PR apache#62234 to
backfill existing NULLs, but after revisiting the issue we found the
migration was only compensating for the nullability mistake introduced by
PR apache#56330 itself, which has not been released.

Instead of shipping a large corrective migration for an unreleased
regression, delete the migration file and restore the affected ORM fields
to nullable so the models stay aligned with the actual schema and
intended pre-release behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants