Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rakedb:migrate不更改表_Ruby On Rails_Ruby_Rake_Dbmigrate - Fatal编程技术网

Ruby on rails rakedb:migrate不更改表

Ruby on rails rakedb:migrate不更改表,ruby-on-rails,ruby,rake,dbmigrate,Ruby On Rails,Ruby,Rake,Dbmigrate,我有一个带有列(名称、路径)的数据库。现在我有了一个迁移文件,将列更改为(name、pathrig、pathjson、scramble) 执行rake db:reset和rake db:migrate不会更新表。为什么会发生这种情况 我的迁移文件: class CreateUploads < ActiveRecord::Migration def change create_table :uploads do |t| t.string :name t.s

我有一个带有列(名称、路径)的数据库。现在我有了一个迁移文件,将列更改为(name、pathrig、pathjson、scramble)

执行
rake db:reset
rake db:migrate
不会更新表。为什么会发生这种情况

我的迁移文件:

class CreateUploads < ActiveRecord::Migration
  def change
    create_table :uploads do |t|
      t.string :name
      t.string :pathorig
      t.string :pathjson
      t.string :scramble

      t.timestamps
    end
  end
end
对各种
rake db::
命令的作用有很好的解释

因为
rake db:reset
执行
db:schema:load
,它从表中加载旧列,而不是调用
db:migrate
,这就是迁移没有运行的原因

考虑编写一个迁移来更改这些列的名称,而不是重新创建现有表,或者手动运行
rakedb:drop;rake db:create db:migrate

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

  create_table "uploads", force: true do |t|
    t.string   "name"
    t.string   "path"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

end