ruby-on-rails – Rails迁移不会改变schema.rb

我有一个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?

解决方法

documentation

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

Reference

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...