How to add indexes and relationships in an ActiveRecord Migration

Use the execute command (outside the create table loop) to inject SQL statements for whatever isn't covered by the migration syntax (which is limited). For example:

execute "ALTER TABLE items ADD COLUMN cost_unit DECIMAL(5,2) NOT NULL DEFAULT 0"

Also check out the foreign_key_migrations plugin. (http://www.redhillconsulting.com.au/rails_plugins.html). I use it to handle relationships automatically.