Ruby on rails rakedb:migrate不更改表
我有一个带有列(名称、路径)的数据库。现在我有了一个迁移文件,将列更改为(name、pathrig、pathjson、scramble) 执行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
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