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

Use locking mechanism as intended in unsafe_add_column #23

Closed

Conversation

tragiclifestories
Copy link
Contributor

Fixes #22 .

@@ -50,6 +49,12 @@ def self.delegate_unsafe_method_to_migration_base_class(method_name)
disable_or_delegate_default_method :remove_index, ":remove_index is NOT SAFE! Use safe_remove_concurrent_index instead for Postgres 9.6 databases; Explicitly call :unsafe_remove_index to proceed on Postgres 9.1"
disable_or_delegate_default_method :add_foreign_key, ":add_foreign_key is NOT SAFE! Explicitly call :unsafe_add_foreign_key only if you have guidance from a migration reviewer in #service-app-db."

def unsafe_add_column(table, column, type, options = {})
safely_acquire_lock_for_table(table) do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a little unfortunate that we now have an implicit dependency in this file on this method in safe_statements; but the only alternative I can see is calling execute_ancestor_statement in that file, which is not an improvement. Perhaps they could be moved to a separate helper module.

@jcoleman
Copy link
Contributor

jcoleman commented Apr 1, 2019

This is a good catch; I'd like to discuss among our team internally as to the questions about file dependencies, but the approach looks generally correct.

@JonMR
Copy link
Contributor

JonMR commented Jan 31, 2020

Closing the PR for now since it's been open for so long. If someone else wants to pick this up that'd be great.

This is probably a good starting point for #22.

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.

Definition of unsafe_add_column is unused
3 participants