-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LG-1384 Fix phone configuration index (#2989)
**Why**: To prevent full table scans and db outages **How**: Add new index prefixed with user_id to phone_configurations. Drop old index.
- Loading branch information
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
db/migrate/20190604110233_fix_phone_configuration_index.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,22 @@ | ||
class FixPhoneConfigurationIndex < ActiveRecord::Migration[5.1] | ||
disable_ddl_transaction! | ||
|
||
def up | ||
add_index( | ||
:phone_configurations, | ||
%i[user_id made_default_at created_at], | ||
algorithm: :concurrently, | ||
name: 'index_phone_configurations_on_made_default_at', | ||
) | ||
remove_index :phone_configurations, %i[made_default_at created_at] | ||
end | ||
|
||
def down | ||
remove_index :phone_configurations, %i[user_id made_default_at created_at] | ||
add_index( | ||
:phone_configurations, | ||
%i[made_default_at created_at], | ||
algorithm: :concurrently, | ||
) | ||
end | ||
end |
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