You can simply save them in a text file and read them through the File object.
sql = "" source = File.new("./sql/procedures.sql", "r") while (line = source.gets) sql << line end source.close execute sql
It is ugly, but it works. I highly recommend storing stored procedures / triggers inside migrations for easy rollback.
If you are executing the “external file” method, you need to save two additional files for one transfer, one to add all the material and one to delete if:
rake db:rollback
Mike trpcic
source share