Custom DML and schema.rb

Cross post from Stack Overflow (


I had a situation today where I wanted to add a partial postgres index
to a
table in a migration. Naturally this kind of stuff is not possible yet
rails using add_index (it is coming some time)

So, I am forced to use execute statements in my migration.

Now, schema.rb has this comment at the top:

# Note that this schema.rb definition is the authoritative source 

# database schema. If you need to create the application database on
# system, you should be using db:schema:load, not running all the
# from scratch. The latter is a flawed and unsustainable approach
more migrations
# you’ll amass, the slower it’ll run and the greater likelihood for

Unfortunately this execute statement is not tracked in schema.rb the
effect of this is making schema.rb pretty much useless if I have any
custom DML.

Is there any way I can force an execute statement containing DML to
itself into schema.rb ?