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 check constraint #68

Merged
merged 6 commits into from
Jan 13, 2025
Merged

Conversation

marcelofern
Copy link
Contributor

@marcelofern marcelofern commented Jan 9, 2025

Analogous to SaferAddCheckConstraint but does the reverse (-:

Copy link

github-actions bot commented Jan 9, 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 450 0 90 0 100%
src/django_pg_migration_tools/timeouts.py 73 0 30 0 100%
TOTAL 670 0 140 0 100%

3 empty files skipped.

@marcelofern marcelofern force-pushed the safer-remove-check-constraint branch from ed49fe5 to d9a318a Compare January 9, 2025 19:57
@marcelofern marcelofern requested a review from a team January 9, 2025 20:00
@marcelofern marcelofern marked this pull request as ready for review January 9, 2025 20:00
@marcelofern marcelofern force-pushed the safer-remove-check-constraint branch from d9a318a to 0f46299 Compare January 10, 2025 03:03
In order to show the best output to sqlmigrate, i.e., the one that shows
the largest amount of DDL statements while omitting the introspective
queries, we need to alter the "collect_default" value of this function
when adding/removing check constraints

This is a small clean up that will be used in the next commit.
Moves to the tests/example_app/models.py file so that it can be reused
by future models that will need to have a check constraint that works in
multiple versions of Django.
This operation is the counterpoise of SaferAddCheckConstraint.
It allows to remove a check constraint more safely (idempotently), and
also allows for a safer reverse operation (adding the check constraint
back again).
As per e2e14c3 this should avoid some
potentially mistaken copy/paste.
@marcelofern marcelofern force-pushed the safer-remove-check-constraint branch from 0f46299 to d20d8cb Compare January 13, 2025 23:11
@marcelofern marcelofern merged commit d30f568 into main Jan 13, 2025
11 checks passed
@marcelofern marcelofern deleted the safer-remove-check-constraint branch January 13, 2025 23:15
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