I'm just a noob developer and I have a stored procedure I've created for postgres. The app I'm developing has backend done in node and I've got to upload the stored procedure to our dev server.

How is this process usually done? I mean, I could just copy the code and paste it on our dev's pgadmin and that would work. But, creating a migration file for that would also work. Also, executing a CREATE OR REPLACE PROCEDURE raw query inside the code itself would also work.

How is the process of uploading a stored procedure on a postgres running server usually done?

  • Keep your stored procedure creation scripts in git or svn (or whichever source control system you use). Then all you have to do is run that script to create it. Jul 20, 2021 at 10:15
  • yeah, but, @Colin'tHart , how would we run a script for postgres outside of it? Are you suggesting some sort of a raw ORM query?
    – juztcode
    Jul 26, 2021 at 15:52
  • 1
    It’s as easy as psql -f script.sql Jul 26, 2021 at 16:02

1 Answer 1


You just connect to the postgres database instance, run the create procedure query, grant permissions to execute it to whatever role/users that you want to grant access to, and call it a day.

Not the answer you're looking for? Browse other questions tagged or ask your own question.