Rails: Adding an index after adding column

前端 未结 6 789
死守一世寂寞
死守一世寂寞 2020-12-22 22:18

Suppose I created a table table in a Rails app. Some time later, I add a column running:

rails generate migration AddUser_idColumnToTable user_i         


        
6条回答
  •  忘掉有多难
    2020-12-22 22:49

    Add in the generated migration after creating the column the following (example)

    add_index :photographers, :email, :unique => true
    

提交回复
热议问题