2007-12-20

Rails宝典八十三式:Migrations in Rails 2.0

关键字: rails 2.0 migration
Migrations are now sexy in Rails 2.0!

创建当前environme的数据库
rake db:create


创建所有environme的数据库
rake db:create:all


创建和修改Model
script/generate model task name:string priority:integer
script/generate migration add_description_to_task description:string
script/generate migration remove_description_from_task description:string


看看自动生成的migration文件
# migrations/001_create_tasks.rb
create_table :tasks do |t|
  t.string :name
  t.integer :priority, :position
  t.timestamps
end

# migrations/002_add_description_to_task.rb
add_column :tasks, :description, :text

# migrations/003_remove_description_from_task.rb
remove_column :tasks, :description
评论
发表评论

您还没有登录,请登录后发表评论

hideto
搜索本博客
我的相册
A6bdc31c-c66e-468e-961e-9cc721e82adc-thumb
screenshot
共 1 张
存档
最新评论