-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRY up: Extract #remove_index override into Module
Signed-off-by: Alex Coles <alex@alexbcoles.com>
- Loading branch information
Showing
5 changed files
with
17 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module SchemaPlus::Indexes | ||
module RemoveIfExists | ||
# Extends rails' remove_index to include this options: | ||
# :if_exists | ||
def remove_index(table_name, *args) | ||
options = args.extract_options! | ||
if_exists = options.delete(:if_exists) | ||
args << options if options.any? | ||
return if if_exists && !index_name_exists?(table_name, options[:name] || index_name(table_name, *args), false) | ||
super table_name, *args | ||
end | ||
end | ||
end |