In this chapter we looked at the process of creating and managing stored objects (procedures, functions, and triggers). Let’s conclude with an outline of what we regard as the best practices for creating and managing stored objects:
Make sure that the reference (e.g., official) copy of each of your stored programs exists as a file on disk, not as the copy stored in the MySQL server. Stored programs might need to be shared between multiple servers, and you therefore need at least one copy—not on a server—that represents the current version.
Use a version control system to maintain a copy of any version of a stored program that is deployed to a MySQL server. In other words, subject stored program code to the same discipline that you apply to other program code.
When you are editing a stored program, check it out of the source control system and load the checked-out copy into the MySQL Query Browser or other tool.
When you are satisfied with your changes, save the stored program code to a disk file and check it into the version control system.
Deploy the stored program by creating command-line routines using the MySQL client program, and embed these into Make files or other build/deploy scripts that you can use to apply schema changes and other server object changes.