Class: MailboxerNamespacingCompatibility

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/mailboxer/templates/mailboxer_namespacing_compatibility.rb

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/mailboxer/templates/mailboxer_namespacing_compatibility.rb', line 16

def self.down
  rename_table :mailboxer_conversations, :conversations
  rename_table :mailboxer_notifications, :notifications
  rename_table :mailboxer_receipts,      :receipts

  if Rails.version < '4'
    rename_index :notifications, :mailboxer_notifications_on_conversation_id, :notifications_on_conversation_id
    rename_index :receipts,      :mailboxer_receipts_on_notification_id,      :receipts_on_notification_id
  end

  Mailboxer::Notification.where(type: 'Mailboxer::Message').update_all(type: 'Message')
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/mailboxer/templates/mailboxer_namespacing_compatibility.rb', line 3

def self.up
  rename_table :conversations, :mailboxer_conversations
  rename_table :notifications, :mailboxer_notifications
  rename_table :receipts,      :mailboxer_receipts

  if Rails.version < '4'
    rename_index :mailboxer_notifications, :notifications_on_conversation_id, :mailboxer_notifications_on_conversation_id
    rename_index :mailboxer_receipts,      :receipts_on_notification_id,      :mailboxer_receipts_on_notification_id
  end

  Mailboxer::Notification.where(type: 'Message').update_all(type: 'Mailboxer::Message')
end