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
After generating a migration rails generate migration CreateBoards name:string description:string
In the migration file, add index as shown below:
class CreateBoards < ActiveRecord::Migration
def change
create_table :boards do |t|
t.string :name
t.string :description
t.timestamps
end
add_index :boards, :name, unique: true
end
end