Managing Stored Procedures (SPs) and/or User Defined Functions (UDFs) is challenging. I'm coming from Postgres-land, so I'm going to stick with saying "UDFs" for the rest of the issue.
Most people I know put each UDF in a file, and then upgrades are managed fairly easily with something like alembic. Downgrades, on the other hand, are very difficult to figure out.
Some ideas that were thrown around that might help solve this problem include:
- SQLAlchemy models generating an UDF-based unit-of-work
- Serialized version of previous state of the database that can be fully restored (issue 117 https://bitbucket.org/zzzeek/alembic/issue/117/autogen-from-persisted-metadata)
I'm most interested in solving the downgrade issue, regardless of other use cases.