Skip to content

Commit

Permalink
Added missing STI and reference indices on mailboxer_conversation_opt…
Browse files Browse the repository at this point in the history
…_outs, mailboxer_notifications, and mailboxer_receipts.

Please note, that "functional" indices (e.g., read/unread messages, etc.) should be added in the future as well.
  • Loading branch information
Leonid Beder committed Aug 16, 2014
1 parent 6e79c17 commit 2564da6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions db/migrate/20131206080417_add_missing_indices.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AddMissingIndices < ActiveRecord::Migration
def change
# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_conversation_opt_outs, [:unsubscriber_id, :unsubscriber_type],
name: 'index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type'
add_index :mailboxer_conversation_opt_outs, :conversation_id

add_index :mailboxer_notifications, :type
add_index :mailboxer_notifications, [:sender_id, :sender_type]

# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_notifications, [:notified_object_id, :notified_object_type],
name: 'index_mailboxer_notifications_on_notified_object_id_and_type'

add_index :mailboxer_receipts, [:receiver_id, :receiver_type]
end
end
6 changes: 5 additions & 1 deletion lib/generators/mailboxer/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def create_initializer_file

def copy_migrations
if Rails.version < "3.1"
migrations = [["20110511145103_create_mailboxer.rb","create_mailboxer.rb"], ["20131206080416_add_conversation_optout.rb","add_conversation_optout.rb"]],
migrations = [
%w[20110511145103_create_mailboxer.rb create_mailboxer.rb],
%w[20131206080416_add_conversation_optout.rb add_conversation_optout.rb],
%w[20131206080417_add_missing_indices.rb add_missing_indices.rb]
],
migrations.each do |migration|
migration_template "../../../../db/migrate/" + migration[0], "db/migrate/" + migration[1]
end
Expand Down

0 comments on commit 2564da6

Please sign in to comment.