I have to create a Rails migration which creates many triggers and stored procedures.
Normally one would do that using the execute method, but because of the size of the statements, I’d rather keep them in an external file and reference it from the migration.
How can I do that? Is it even possible?
You can just store them in a text file and read them in via a File object.
It’s ugly, but works. I’d strongly recommend keeping the stored procedures/triggers inside migrations for easy rollbacks.
If you do the “external file” method, you’ll need to maintain two additional files per migration, one for adding all the stuff, and one for dropping in in case of a: