M
M
Mat1lda2021-04-15 18:12:35
PostgreSQL
Mat1lda, 2021-04-15 18:12:35

How to version code in plpgsql?

The bottom line is this: I want to write logic in plpgsql and call it from go, how would it be more correct to develop stored procedures so that I can tie it all to git? (So ​​that the procedures are stored not only in the database, but also locally in the file). Is there a trickier method than just storing the .sql extension files locally?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-04-15
@Mat1lda

Is there a trickier method than just storing the .sql extension files locally?
no, most likely. Git works with files anyway.
You will need a script that will unload and load these files from / to the database (pg_dump can not only extract functions and even into separate files, so it's some kind of SELECT FROM pg_proc plus pg_get_functiondef () can be a start).
Plus, there will be separate problems when the input parameters of the functions change. PG has polymorphism, so CREATE OR REPLACE FUNCTION will create new functions. You will need to manually remove outdated versions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question