rails 添加刪除表 字段

http://blog.csdn.net/li_001/article/details/53857336

增加表
rails g model water_temperature position:integer name:string en_name:string

刪除新增錯(cuò)誤的表
rails d model water_temperature position:integer name:string en_name:string

新增表字段
rails g migration add_column_water_temperature_id_into_product
def up
add_column :products, :water_temperature_id, :integer
end
def down
remove_column :water_temperature_id
end

刪除表字段
rails g migration remove_column_water_temperature_id_into_product
def change
remove_column :skus, :face_price_id
end

修改字段
rails g migration rename_column_seat_powers_id_into_product
def up
rename_column :products, :seat_powers_id, :seat_power_id
end

def down
rename_column :products, :seat_power_id, :seat_powers_id
end

修改字段屬性
rails g migration change_column_seat_powers_into_product
def up
change_column :products, :seat_powers, :string
end

def down
change_column :products, :seat_powers, :integer
end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容