You can always execute arbitrary SQL in migrations. For instance:
def up
execute('ALTER TABLE people ADD INDEX ...')
end
The one thing to keep in mind though is that if you use ruby schema format, your tests won't pick up those execute statements. In that case it's best to either use the sql format or re-run migrations in the test environment to set up the test db.
Upgrading from Rails 3.2 to Rails 4.0 takes very little time, assuming the gems you depend on are compatible (which they should be, by now, or you might want to look for replacement gems..)