代码之家  ›  专栏  ›  技术社区  ›  BDeGiglio

迁移正在挂起。要解决此问题,请运行:bin/rake-db:migrate RAILS_ENV=development

  •  1
  • BDeGiglio  · 技术社区  · 12 年前

    This is the error I am getting 当我试图查看我用ruby on rails创建的页面时。问题是,我已经将数据库从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
    

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

    1 回复  |  直到 11 年前
        1
  •  3
  •   BDeGiglio    11 年前

    好吧,我想我已经想通了。我跑了 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/rake db:create db:migrate

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