Postgresql – Best way to move functions from postgresql to another

postgresql

I'm not familiar with postgres but I'm sure there has to be a way to source control its functions.
Currently my team adds functions on a postgresql database directly, and when it's time to deploy to production they just move the functions manually, so it's natural to forget to move certain functions.

Is there a tool similar to git that would allow them to branch out, merge and deploy?

Best Answer

You can use a custom PostgreSQL extension created with CREATE EXTENSION.

Put all of your extension code in a build system and have your developers work on that. Then you can install the extensions easily and version control them, roll them back, upgrade them, etc.

Here is a tutorial to get started.