原创作者: hideto   阅读:1811次   评论:0条   更新时间:2011-05-26    
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
评论 共 0 条 请登录后发表评论

发表评论

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

文章信息

Global site tag (gtag.js) - Google Analytics