【发布时间】:2017-01-31 11:49:15
【问题描述】:
我正在尝试销毁我的 ROR 应用程序中的一个对象。
但我收到以下错误:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "mailboxer_conversation_opt_outs" does not exist
LINE 5: WHERE a.attrelid = '"mailboxer_conversation_o...
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"mailboxer_conversation_opt_outs"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:584:in `execute_and_clear'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:733:in `column_definitions'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:186:in `columns'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/schema_cache.rb:49:in `columns_hash'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/associations/association_scope.rb:85:in `column_for'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/associations/association_scope.rb:94:in `bind'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/associations/association_scope.rb:103:in `last_chain_scope'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/associations/association_scope.rb:139:in `add_constraints'
... 72 levels...
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:281:in `block in destroy'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:220:in `transaction'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:281:in `destroy'
from (irb):5
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:in `start'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
我猜这与我的应用程序中没有的 mailboxer_conversation_opt_outs 表有关。
我正在使用 Rails 4.2 并且:
mailboxer (0.13.0)
carrierwave (>= 0.5.8)
foreigner (>= 0.9.1)
rails (>= 3.2.0)
有没有我错过的迁移文件?
我的对象怎么连接到这张表,而实际的对象却不能发送消息?
谢谢
【问题讨论】:
-
你试过运行
rake db:migrate吗?你的schema_migrations表中有20131206080416_add_conversation_optout吗? -
不。我猜这个迁移是在我一开始(大约 3 年前)设置邮箱之后添加的,对吧?我应该如何赶上这个?
-
好吧,我会看看您的
schema_migrations表中是否存在该迁移。在我的本地,我会删除数据库并重新创建它并再次运行迁移,看看是否解决了它 -
迁移不存在,我的问题正在生产中发生,所以我不能删除我的数据库...如果这是来自较新版本,我想应该有一些升级步骤我错过了什么?