Rails5 マイグレーションファイルでのindexの書き方が変わった
add_index
で書いていた箇所がカラム追加と同じメソッド内にt.index
という形で書けるようになったみたいです。
Class CreateQuestions < ActiveRecord::Migration[5.0] def change create_table :questions do |t| t.string :title t.text :content t.index :title, unique: true #こんな感じ end end end
元の書き方でも動きますが、すっきり!