This repository has been archived by the owner on May 13, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring over command recorder remove_index :if_exists that was in schem…
…a_plus_foreign_key (or should it go in schema_plus_indexes?)
- Loading branch information
Showing
2 changed files
with
15 additions
and
0 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
14 changes: 14 additions & 0 deletions
14
lib/schema_plus/auto_foreign_keys/active_record/migration/command_recorder.rb
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,14 @@ | ||
module SchemaAutoForeignKeys | ||
module ActiveRecord | ||
module Migration | ||
module CommandRecorder | ||
|
||
# overrides to add if_exists option | ||
def invert_add_index(args) | ||
table, columns, options = *args | ||
[:remove_index, [table, (options||{}).merge(column: columns, if_exists: true)]] | ||
end | ||
end | ||
end | ||
end | ||
end |