【发布时间】:2013-12-11 16:31:41
【问题描述】:
我目前正在将带有 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)
这与设计有关吗?不知道在这里做什么。
还有一些受访者一直在问我是否有用户表:<.br>
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
【问题讨论】:
-
你有迁移到创建的用户表吗?
-
试试this
-
我没有专门针对 users 表的迁移,看起来 Devise 在导致错误的迁移中为我做了这件事。这一切都在本地工作。而且我确实有一个用户模型。
标签: ruby-on-rails ruby heroku devise migration