PostgreSQL function rework

41 views
Skip to first unread message

Steve Marks

unread,
Aug 2, 2021, 7:18:49 AM8/2/21
to Sqitch Users
Hi All, 

I have a question about reworking functions in Sqitch. 

I have a file "functions_create" which has all our create functions in there. these create tables with data merged from multiple other tables. 

I need to rework one of these functions what is the correct way to do this: 

1. run rework, delete all the functions from the file and just update the function that I need
2. run rework, leave all the functions in the file and just update the function that needs changing

I assume option 2 is correct as then we can diff files between git versions? but it creates so much duplication in the versioned files! 

François Beausoleil

unread,
Aug 2, 2021, 7:44:35 AM8/2/21
to Steve Marks, Sqitch Users
Hi!

I have a single file per function name. Given PG is polymorphic, I believe that this gives me the most flexibility.

I also have a file per schema, table and view. Because views and functions can use “CREATE OR REPLACE”, I will rework those changes. Otherwise, other changes go into a separate migration file.

My hierarchy looks like:

* schemas/app
* functions/maintain_timestamps
* tables/users
* migrations/add_oauth_to_users
* views/monthly_active_users_report

Hope that helps!
François

Le 2 août 2021 à 07:18, Steve Marks <marks...@gmail.com> a écrit :

Hi All, 
--
You received this message because you are subscribed to the Google Groups "Sqitch Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqitch-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqitch-users/9c89a65f-c9fa-46c6-9df0-fb64c3d8e22cn%40googlegroups.com.

Steve Marks

unread,
Aug 2, 2021, 8:26:55 AM8/2/21
to Sqitch Users
Ok interesting, 

So do you have subfolders inside each of the deploy/revert/verify folders:

migrations
- deploy
-- functions
---- maintain_timestamps.sql
- revert 
-- functions
----- maintain_timestamps.sql

I didn't realise that subfolders was supported that does change things quite a bit though as then I can split out all the functions, the reason we didn't do it before is due to the sheer volume of functions that we have. 
Reply all
Reply to author
Forward
0 new messages