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

Bug Fix for unsafe_remove_check_constraint in certain Rails version #102

Merged

Conversation

imsurajmishra
Copy link
Contributor

@imsurajmishra imsurajmishra commented Jun 26, 2024

We identified that for certain rails version ( 6.1+, 7.0 ) , when we use symbol for constraint name, migration fails :

> -- remove_check_constraint("test_models", {:name=>:constraint_check_on_test_int_foo})
ArgumentError: Table 'test_models' has no check constraint for {:name=>:constraint_check_on_test_int_foo}

the bug is in this code path :
https://github.com/rails/rails/blob/16d8b82d5e2aca4780c5d10b1fe9a90b33a0e84e/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L1772-L1773

Note: this bug has been fixed in rails 7.1

This PR mainly overriding unsafe_remove_check_constraint method and converts name arg to name.to_s

@imsurajmishra imsurajmishra force-pushed the bug-fix-for-constraint-name branch from b03ab0f to f8a5c78 Compare June 26, 2024 02:59
@imsurajmishra imsurajmishra changed the title wip Bug Fix for unsafe_remove_check_constraint in certain Rails version Jun 26, 2024
spec/safe_statements_spec.rb Outdated Show resolved Hide resolved
lib/pg_ha_migrations/safe_statements.rb Outdated Show resolved Hide resolved
@imsurajmishra imsurajmishra force-pushed the bug-fix-for-constraint-name branch from 81893d4 to 33b712b Compare June 26, 2024 13:29
@imsurajmishra imsurajmishra marked this pull request as ready for review June 26, 2024 13:32
lib/pg_ha_migrations/safe_statements.rb Outdated Show resolved Hide resolved
spec/safe_statements_spec.rb Outdated Show resolved Hide resolved
spec/safe_statements_spec.rb Outdated Show resolved Hide resolved
@imsurajmishra imsurajmishra force-pushed the bug-fix-for-constraint-name branch from 1335630 to c09081e Compare July 8, 2024 20:32
@imsurajmishra imsurajmishra force-pushed the bug-fix-for-constraint-name branch from c09081e to ff28275 Compare July 8, 2024 20:33
@jcoleman jcoleman merged commit 1548086 into braintree:master Jul 8, 2024
46 checks passed
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.

4 participants