Don*_*n P 1 ruby rake ruby-on-rails dbmigrate
我有一个带有列(名称,路径)的数据库.现在我有一个迁移文件,可以将列更改为(name,pathorig,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
Run Code Online (Sandbox Code Playgroud)
schema.rb文件:
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
Run Code Online (Sandbox Code Playgroud)
rake db:migrate db:reset和db:schema:load之间的区别对各种rake db:*命令的作用有很好的解释.
因为rake db:reset执行a db:schema:load,它正在从表中加载旧列,而不是调用db:migrate,这就是为什么不运行迁移的原因.
考虑编写一个更改这些列名称的迁移,而不是重新创建现有表,或手动运行 rake db:drop; rake db:create db:migrate
| 归档时间: |
|
| 查看次数: |
2895 次 |
| 最近记录: |