我有一個現有模型'micropost',我發現模型的名稱更適合我的應用。在不影響其索引的情況下,將'micropost'模型重命名爲'story'模型會更好嗎?我正在使用Rails 5.0.0.rc1。遷移片段爲:帶遷移的重命名模型
class CreateMicroposts < ActiveRecord::Migration
def change
create_table :microposts do |t|
t.text :content
t.references :user, index: true
t.timestamps null: false
end
add_index :microposts, [:user_id, :created_at]
end
end
如果數據庫在本地,然後去chnage所有的名字根據自己的需要,否則,創建一個遷移重命名同樣的事情。 –
@Bharatsoni感謝您的及時回覆。我應該使用up和down方法嗎?還是有更好的方法? – veekram