Skip to content

Use PRAGMA defer_foreign_keys instead of PRAGMA foreign_keys when migrating #35873

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ferferga
Copy link

This Pull Request changes the use of PRAGMA foreign_keys in SQLite migrations to PRAGMA defer_foreign_keys, which are allowed inside transactionss without any issue.

It's one of the possible fixes for #35871, and I think the best one, since we will use the exact pragma that SQLite wants to be used for transactions, instead of working around it.

I did my best attempt to update the tests as well, but not sure this is how I should do it (since I didn't see any mention to BEGIN TRANSACTION inside the generated SQL in tests.

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

… migrating

defer_foreign_keys is specifically tailored to be used inside
SQLite transactions.

Reference issue: dotnet#35871
@ferferga
Copy link
Author

@dotnet-policy-service agree

@roji roji requested a review from cincuranet March 30, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants