-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix DB migrations from 2.10.5 to 3.0.0 for SQlite #49301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kaxil
approved these changes
Apr 15, 2025
sunank200
approved these changes
Apr 15, 2025
eladkal
approved these changes
Apr 15, 2025
fae5393 to
63061de
Compare
Through some means I haven't been able to uncover, the FKs we end up with
when upgrading a DB from 2.10.5 are duplicated:
```
CONSTRAINT ds_dsa_alias_id FOREIGN KEY(alias_id) REFERENCES dataset_alias (id) ON DELETE CASCADE,
CONSTRAINT ds_dsa_dataset_id FOREIGN KEY(dataset_id) REFERENCES dataset (id) ON DELETE CASCADE,
CONSTRAINT dataset_alias_dataset_alias_id_fkey FOREIGN KEY(alias_id) REFERENCES dataset_alias (id) ON DELETE CASCADE,
CONSTRAINT dataset_alias_dataset_dataset_id_fkey FOREIGN KEY(dataset_id) REFERENCES dataset (id) ON DELETE CASCADE
```
SQLite doesn't even officially have `DROP CONSTRAINT`, let alone an `IF
EXISTS` modifier on it, but with a little bit of work we can make it work with
the tools Alembic gives us.
63061de to
85bf552
Compare
Member
Author
|
I've totally re-written this, so I've requested re-reviews |
dstandish
approved these changes
Apr 15, 2025
ephraimbuddy
approved these changes
Apr 15, 2025
kaxil
pushed a commit
that referenced
this pull request
May 19, 2025
## Why `airflow db migrate` failed when I migrated an old airflow instance to 2.11.0rc1 ## What Following up #49301 and trying to fix some found issues * `0093 upgrade, 0100 upgrade, 0060 downgrade, 0064 downgrade`: since SQite does not support constant drop, follow how #49301 deals with fk for SQlite * `0110`: backport _drop_fkey_if_exists for handling fk in sqlite * `0142`: Explicitly list down the column names when recreating dag_run table * `0073`: add a safeguard to ensure we're not wrongly update the name
This was referenced Jun 3, 2025
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
priority:high
High priority bug that should be patched quickly but does not require immediate new release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hrough some means I haven't been able to uncover, the FKs we end up with
when upgrading a DB from 2.10.5 are duplicated:
SQLite doesn't even officially have
DROP CONSTRAINT, let alone anIF EXISTSmodifier on it, but with a little bit of work we can make it work withthe tools Alembic gives us.
Fixes #49296
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.