我目前正在将带有ruby 2.0的rails 3.2应用程序推送到heroku。我已成功将代码推送到新的heroku服务器,现在我正在尝试迁移数据库,然后播种它。
当我运行命令
时$ heroku run rake:db:migrate
我收到错误:
Running `rake db:migrate` attached to terminal... up, run.8854
Connecting to database specified by DATABASE_URL
Migrating to CreateRoutines (20130720183354)
Migrating to CreateExercises (20130720183503)
Migrating to CreateLifts (20130720183601)
Migrating to CreateInfos (20130723010806)
Migrating to AddUserIdToRoutine (20130808142746)
Migrating to AddBodyweighToRoutine (20130810164534)
Migrating to AddDeviseToUsers (20131003183650)
== AddDeviseToUsers: migrating ===============================================
-- change_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "users" does not exist
: ALTER TABLE "users" ADD COLUMN "email" character varying(255) DEFAULT '' NOT NULL/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `exec'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `block in execute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in `execute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1022:in `add_column'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_definitions.rb:479:in `block in string'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_definitions.rb:468:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_definitions.rb:468:in `string'
/app/db/migrate/20131003183650_add_devise_to_users.rb:5:in `block in up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:243:in `change_table'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:466:in `block in method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:458:in `method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:334:in `method_missing'
/app/db/migrate/20131003183650_add_devise_to_users.rb:3:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:389:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
这是与Devise有关吗?不知道该怎么做。
也有一些受访者一直在询问我是否有用户表:&lt; .br&gt;
create_table "users", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "provider"
t.string "uid"
end
答案 0 :(得分:0)
错误表示您正在尝试更改表users
,但该表不存在。
您应该已将表创建为另一个迁移的一部分,或者检查设计安装的文档。我非常确定有创建必要表格的说明而不是更改它。
我快速查看at the documentation,我相信该程序在命令的“入门”部分中描述
rails generate devise MODEL