#107 Migrations in Rails 2.1

Migrations now have a timestamp as their version number in Rails 2.1. In this episode I will explain this change as well as show you some other cool additions.
# in a migration file
def self.up
change_table :products do |t|
t.rename :released_on, :released_at
t.change :description, :text, :limit => nil, :null => true
t.remove :price
t.integer :stock_quantity
end
end

def self.down
change_table :products do |t|
t.rename :released_at, :released_on
t.change :description, :string, :null => false
t.decimal :price, :precision => 10, :scale => 2
t.remove :stock_quantity
end
end
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章