I would be really interested in how you maintain your database code if you are up for another write up or have some time to chat.
I would be really interested in how you maintain your database code if you are up for another write up or have some time to chat.
- For plpgsql functions that are required by app queries, we just roll them out when we write them / when they change (via ansible).
- For plpgsql functions used in jobs, the job just reloads the relevant plpgsql functions on the relevant DBs before they start doing anything. (It's a little wasteful, but not in a way that matters for now.)
- The UDFs we've written in C don't change too often, but we deploy them manually when they do.
What are some of the headaches you've had in managing stored procs? How often is your app code changing / requiring new ones?
We solved it with a small wrapper around the calls to plpgsql functions — we set up a build process to generate unique names that were called by version. During deploy, we'd have two or more versions of the 'same' function running in parallel. The last deploy step dropped the now-outdated functions.
It worked relatively well.
Once you get beyond normal queries and enter the realm of real database development you likely want someone who is a genuine database developer.
I'm worked with several database developers plus my wife is a database developer. They are a different breed, and they really develop applications in the data layer.
I can say from experience that once you add a database developer you'll never look at the data layer the same. Often, there is a substantial amount of work that can be performed better by the database (whether it's Oracle, SQL Server, Postgres or whatever) since they have 30+ years of tuning for specific data operations.
I have seen other ways to deploy stored procedures but these often require being very careful about function API:s and delta scripts.