新手问题 migration 的问题

Yunich · December 20, 2012 · Last by Yunich replied at December 20, 2012 · 2161 hits

我在看这里的教程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的功能。

You need to Sign in before reply, if you don't have an account, please Sign up first.