我升级了mailboxer gem,并按照文档中的步骤从0.11升级到0.12:
$ rails generate mailboxer:namespacing_compatibility
create db/migrate/20140707050845_mailboxer_namespacing_compatibility.rb
$ rails generate mailboxer:install -s
skip config/initializers/mailboxer.rb
Copied migration 20140707050855_add_conversation_optout.mailboxer_engine.rb from mailboxer_engine然后当我试着
$ rake db:migrate它给了我一个错误
PG::UndefinedTable: ERROR: relation "notifications_on_conversation_id" does not exist有什么建议这是什么意思?该如何修复呢?
谢谢
发布于 2014-10-09 03:51:00
我在从mailboxer 0.9.0升级到0.12.4 (在rails 3.2.19上)时遇到了同样的问题。
我所做的是手动编辑由namespacing_compatibility生成器创建的迁移,如下所示:
rename_index命令中使用"index_“作为"from”索引名称的前缀。update_all命令移到开头,放在rename_table命令之前。H210F211我编辑后的迁移结果是这样的。在这里,我用注释起诉了编辑过的行。
class MailboxerNamespacingCompatibility < ActiveRecord::Migration
def self.up
rename_table :conversations, :mailboxer_conversations
rename_table :notifications, :mailboxer_notifications
rename_table :receipts, :mailboxer_receipts
if Rails.version < '4'
# i edited the next two lines by adding the index_ prefix
rename_index :mailboxer_notifications, :index_notifications_on_conversation_id, :mailboxer_notifications_on_conversation_id
rename_index :mailboxer_receipts, :index_receipts_on_notification_id, :mailboxer_receipts_on_notification_id
end
Mailboxer::Notification.where(type: 'Message').update_all(type: 'Mailboxer::Message')
end
def self.down
# i moved this line from the end of the down block to here
Mailboxer::Notification.where(type: 'Mailboxer::Message').update_all(type: 'Message')
rename_table :mailboxer_conversations, :conversations
rename_table :mailboxer_notifications, :notifications
rename_table :mailboxer_receipts, :receipts
if Rails.version < '4'
# i edited the next two lines by adding the index_ prefix
rename_index :notifications, :mailboxer_notifications_on_conversation_id, :index_notifications_on_conversation_id
rename_index :receipts, :mailboxer_receipts_on_notification_id, :index_receipts_on_notification_id
end
end
end然后,我运行迁移,运行另一个(mailboxer:install)生成器,并运行该迁移。到目前为止,情况似乎还不错。
https://stackoverflow.com/questions/24603483
复制相似问题