新手问题 migration 的问题

Yunich · 2012年12月20日 · 最后由 Yunich 回复于 2012年12月20日 · 2159 次阅读

我在看这里的教程http://guides.ruby.tw/rails3/migrations.html 时看到 rails generate model Product name:string description:text 时给出的代码是

class CreateProducts < ActiveRecord::Migration
  def self.up
    create_table :products do |t|
      t.string :name
      t.text :description

      t.timestamps
    end
  end

  def self.down
    drop_table :products
  end
end

但是我自己运行生成的 rb 文件里只有一个 class 下面只有一个change方法,这是 rails 版本原因造成的么?这样的差异有什么后果?求解释下

新版本确实是只有一个change了,它包含了updown的功能。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号