我想在我的rails 4 app中使用mailboxer.当我尝试部署数据库时出现问题.创建邮箱会话表时出错,该表在通知表中具有依赖关系.
我正在尝试删除通知对话的外键.
我创建了一个迁移说:
change_table :notifications do |t|
t.remove_foreign_key :conversations
Run Code Online (Sandbox Code Playgroud)
但是,rake中止并说外键不存在.
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::UndefinedObject: ERROR: constraint "notifications_conversation_id_fk" of relation "notifications" does not exist
Run Code Online (Sandbox Code Playgroud)
我的架构包括:add_foreign_key"notifications","conversation",name:"notifications_on_conversation_id"
我试图挖掘db:migrate:down创建邮箱的原始迁移,但也收到错误,说'找不到命令'.
有人可以帮忙吗?谢谢.
这很可能是一个菜鸟问题,因为人们使用这个宝石并且很多人喜欢它,但我没有达到目的.我期待在项目及其在这里多次使用的地方,如t.references :foreign_key_table_name , :foreign_key => true,add_foreign_key :table :foreign_key_table_name, :options以及在创建t.foreign_key :foreign_key_table_name.希望这些不会让人感到困惑,因为它们已脱离背景.
但是我不知道这与t.references :foreign_key_table_name我刚刚添加的内置轨道有何不同t.integer :foreign_key_table_name_id?通过明确这是一个"外键",它是否只是让它更具可读性?如果是这样的话,我可以添加注释而不是gem ...我看到的唯一优势是你可以将选项移动:dependent到迁移中而不是在模型中使用它,但是谁在乎呢?