我有一个rails迁移,不适用于我的schema.rb.迁移应该创建一个表:
class CreateUserGraphs < ActiveRecord::Migration def change create_table :user_graphs do |t| t.string :name t.string :content t.integer :user_id t.string :type_id t.integer :upload_id t.timestamps end add_index :user_graphs,[:user_id,:created_at] end end
我做了db:reset.然后我尝试rake db:migrate:up VERSION = 123123123(这是迁移#).我在我的“开发”环境中.
为什么迁移不影响schema.rb?
解决方法
从
@L_404_0@:
rake db:reset任务将丢弃数据库,重新创建它并将当前模式加载到其中.
This is not the same as running all the migrations. It will only use the
contents of the current schema.rb file. If a migration can’t be rolled back,
‘rake db:reset’ may not help you. To find out more about dumping the schema see
‘schema dumping and you.’
所以rake db:reset => db:drop db:create db:schema:load db:seed
要运行所有迁移,请使用:
rake db:drop db:create db:migrate
要么
分贝:迁移:复位=> rake db:drop db:create db:migrate