Skip to content
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

Safer remove field foreign key #69

Merged
merged 6 commits into from
Jan 13, 2025
Merged

Conversation

marcelofern
Copy link
Contributor

This is the analogous of SaferAddFieldForeignKey but does the opposite (-:

Copy link

github-actions bot commented Jan 10, 2025

Coverage Report Results

Name Stmts Miss Branch BrPart Cover
src/django_pg_migration_tools/indexes.py 9 0 0 0 100%
src/django_pg_migration_tools/management/commands/migrate_with_timeouts.py 138 0 20 0 100%
src/django_pg_migration_tools/operations.py 436 0 90 0 100%
src/django_pg_migration_tools/timeouts.py 73 0 30 0 100%
TOTAL 656 0 140 0 100%

3 empty files skipped.

@marcelofern marcelofern marked this pull request as ready for review January 10, 2025 02:34
@marcelofern marcelofern requested a review from a team January 10, 2025 03:15
Copy link
Contributor

@s-cooper18 s-cooper18 left a comment

Choose a reason for hiding this comment

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

LGTM

This will allow us to show the proper queries when running on
collect-only mode (like when running sqlmigrate).

This change will be more useful in a future commit when adding the
SaferRemoveFieldForeignKey operation.
Funny enough the result was the same, though the test was using the
wrong queries list.
This operation is the counterpoise of SaferAddFieldForeignKey.

It allows to remove a foreign key more safely (idempotently), and also
allows for a safer reverse operation (adding the FK field back again).
As per e2e14c3 this should avoid some
potentially mistaken copy/paste.
@marcelofern marcelofern force-pushed the safer-remove-field-foreign-key branch from ce79e53 to 27c39e5 Compare January 13, 2025 22:11
@marcelofern marcelofern merged commit 9b666e3 into main Jan 13, 2025
11 checks passed
@marcelofern marcelofern deleted the safer-remove-field-foreign-key branch January 13, 2025 22:16
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