Mysql 迁移挂起。要解决此问题,请运行:bin/rake db:migrate RAILS\u ENV=development

Mysql 迁移挂起。要解决此问题,请运行:bin/rake db:migrate RAILS\u ENV=development,mysql,ruby-on-rails,ruby,rails-activerecord,rails-migrations,Mysql,Ruby On Rails,Ruby,Rails Activerecord,Rails Migrations,当我试图查看我用RubyonRails创建的页面时。问题是,我已经将数据库从mysql迁移到ruby应用程序。我可以在schema.rb文件夹中看到它 ActiveRecord::Schema.define(version: 0) do create_table "users", force: true do |t| t.string "first_name", null: false t.string "last_name", null: false t.st

当我试图查看我用RubyonRails创建的页面时。问题是,我已经将数据库从mysql迁移到ruby应用程序。我可以在schema.rb文件夹中看到它

ActiveRecord::Schema.define(version: 0) do

  create_table "users", force: true do |t|
    t.string "first_name", null: false 
    t.string "last_name",  null: false
    t.string "username",   null: false
    t.string "password",   null: false
    t.string "email",      null: false
  end

end
这是我的迁移文件夹中的迁移文件

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.timestamps
    end
  end
end
class CreateUsers

我所要做的就是为那个数据库运行一个scaffold,我不断地得到错误。

好的,我想我已经找到了答案。由于上面的一条评论,我运行了
rake db:migrate--trace
,得到了一个巨大的错误,该错误始于:

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: Unknown database 'recipe_library_development'Run `$ bin/rake db:create db:migrate` to create your database
因此,基于此,我运行了:
bin/rakedb:createdb:migrate


我重新加载了我的页面,错误消失了。

如果这些列(名字、姓氏等)不在迁移中,您的表如何包含这些列?define(版本:0)表示数据库从未迁移过,当您迁移它时,此数字会更新为迁移时间戳,并且看起来应该类似于:define(版本:20140810211014)。可能您的迁移由于任何原因都没有成功,请尝试再次运行迁移并检查是否有错误。将
rake db:migrate--trace
的输出添加到您的问题中,或添加到要点中。我在页面上消除了错误(通过我在下面的回答中采取的措施)它将版本更改为ActiveRecord::Schema.define(版本:20140813133141),我想这是件好事。但是,当我这样做时,它删除了关于数据库的所有信息(t.string“first\u name”,null:false t.string“last\u name”,null:false)