How to add indexes and relationships in an ActiveRecord Migration

indexes are simple

add_index :table_name, :column_name

or for multiple columns

add_index :table_name, [:column_name1, :column_name2, ...]

and to remove an index

remove_index :table_name, :column_name

in the case of a multi-column index, rails just uses the first column
name to generate the index name, so in order to remove it, just
provide the first column in the index

for creating foreign key relationships, it is also quite simple but
there are no built-in rails methods for creating them. in self.up,
after your create_table call, add

execute "alter table things add constraint fk_things_widget_id foreign
key (widget_id) references widgets(id)"

and in self, down, before the drop_table call, add

execute "alter table things drop foreign key fk_things_widget_id"