How do I create a new table, through a rails migration, and add an unique index to it?
In the docs I found how to add a index to a table after it\'s been created, but h
A more compact way:
class CreateFoobars < ActiveRecord::Migration def change create_table :foobars do |t| t.string :name, index: {unique: true} end end end