我只是继承了我试图为其运行迁移的代码,但我不断收到 rake aborted 错误。我遇到过其他似乎有类似问题的人,但大多数涉及 Heroku,我正在尝试在本地运行它(开始。)
我已经尝试使用 PostgreSQL 和 SQLite 进行故障排除,并且都产生了相同的问题。引用的表“角色”是调用的第二个迁移,所以我很难弄清楚是什么导致它无法构建。非常感谢任何和所有的帮助。提前致谢。
这是角色迁移:
class CreateRoles < ActiveRecord::Migration
def change
create_table :roles do |t|
t.string :name
t.timestamps
end
end
end
这是 SQLite 的跟踪:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Could not find table 'roles'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/sqlite_adapter.rb:470:in `table_structure'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/sqlite_adapter.rb:351:in `columns'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `yield'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `default'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `columns'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:248:in `column_names'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:261:in `column_methods_hash'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/dynamic_matchers.rb:69:in `all_attributes_exists?'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/dynamic_matchers.rb:27:in `method_missing'
/Users/sa/Documents/AptanaWorkspace/recprototype/config/initializ
ers/constants.rb:1:in `<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `block in load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:236:in `load_dependency'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:588:in `block (2 levels) in <class:Engine>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:587:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:587:in `block in <class:Engine>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:30:in `instance_exec'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:30:in `run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:55:in `block in run_initializers'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:54:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:54:in `run_initializers'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:136:in `initialize!'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/rail
tie/configurable.rb:30:in `method_missing'
/Users/sa/Documents/AptanaWorkspace/recprototype/config/environme
nt.rb:5:in `<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `block in require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:236:in `load_dependency'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:103:in `require_environment!'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:292:in `block (2 levels) in initialize_tasks'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:205:in `call'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:205:in `block in execute'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:200:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:200:in `execute'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:158:in `block in invoke_with_call_chain'
/Users/sa/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in
`mon_synchronize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:151:in `invoke_with_call_chain'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:176:in `block in invoke_prerequisites'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:174:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:174:in `invoke_prerequisites'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:157:in `block in invoke_with_call_chain'
/Users/sa/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in
`mon_synchronize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:151:in `invoke_with_call_chain'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:144:in `invoke'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:116:in `invoke_task'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `block (2 levels) in top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `block in top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:133:in `standard_exception_handling'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:88:in `top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:66:in `block in run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:133:in `standard_exception_handling'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:63:in `run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `
<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => environment
这是 PostgreSQL 的跟踪:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
PG::Error: ERROR: relation "roles" does not exist
LINE 4: WHERE a.attrelid = '"roles"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a
.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"roles"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:1106:in `async_exec'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:1106:in `exec_no_cache'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:650:in `block in exec_query'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/notifications/instrumenter.rb:20:in `instrument'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:649:in `exec_query'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:1231:in `column_definitions'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/postgresql_adapter.rb:845:in `columns'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `yield'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `default'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:228:in `columns'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:248:in `column_names'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/model_schema.rb:261:in `column_methods_hash'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/dynamic_matchers.rb:69:in `all_attributes_exists?'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.1/lib/active
_record/dynamic_matchers.rb:27:in `method_missing'
/Users/sa/Documents/AptanaWorkspace/recprototype/config/initializ
ers/constants.rb:1:in `<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `block in load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:236:in `load_dependency'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:245:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:588:in `block (2 levels) in <class:Engine>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:587:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/engi
ne.rb:587:in `block in <class:Engine>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:30:in `instance_exec'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:30:in `run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:55:in `block in run_initializers'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:54:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/init
ializable.rb:54:in `run_initializers'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:136:in `initialize!'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/rail
tie/configurable.rb:30:in `method_missing'
/Users/sa/Documents/AptanaWorkspace/recprototype/config/environme
nt.rb:5:in `<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `block in require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:236:in `load_dependency'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.1/lib/activ
e_support/dependencies.rb:251:in `require'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:103:in `require_environment!'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.1/lib/rails/appl
ication.rb:292:in `block (2 levels) in initialize_tasks'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:205:in `call'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:205:in `block in execute'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:200:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:200:in `execute'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:158:in `block in invoke_with_call_chain'
/Users/sa/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in
`mon_synchronize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:151:in `invoke_with_call_chain'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:176:in `block in invoke_prerequisites'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:174:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:174:in `invoke_prerequisites'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:157:in `block in invoke_with_call_chain'
/Users/sa/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in
`mon_synchronize'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:151:in `invoke_with_call_chain'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb
:144:in `invoke'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:116:in `invoke_task'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `block (2 levels) in top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `each'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:94:in `block in top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:133:in `standard_exception_handling'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:88:in `top_level'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:66:in `block in run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:133:in `standard_exception_handling'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/applica
tion.rb:63:in `run'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `
<top (required)>'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load'
/Users/sa/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => environment