James A Rosen
DTDrizzle Team
•Created by James A Rosen on 1/1/2025 in #help
Migrations with User-Defined Functions
My current thinking is
1. store the user-defined functions in a directory like
udf/
2. write a script that compares the each function in the directory to the same definition in the database; if they differ, generate a new custom migration to update
3. apply migrations
There are some challenges with this approach:
* if a function's signature changes, we need to drop and re-create, not just create if not exists
* the database normalizes function contents, including changing casing and spacing3 replies
DTDrizzle Team
•Created by z3n on 9/29/2023 in #help
Getting syntax error when using the sql operator (pg)
Following up on this old thread…
Postgres allows setting a setting with the
SET
keyword:
But you can't put SET
in a prepared statement:
Postgres also allows setting a setting with the set_config
function. The third argument is whether the setting is scoped to the transaction (true
) or to the session (false
):
Because it's a function, you can put this in a prepared statement:
Because web applications tend to reuse one Postgres session for many end-users, I recommend passing true
for the third argument. That means you must wrap your work in a transaction. Otherwise, the setting will disappear before your next statement!8 replies