Skip to content

Commit 7704c22

Browse files
authored
Only install pgcrypto if needed (ArroyoSystems#1052)
The `gen_random_uuid` function that Arroyo uses was added to Core in Postgres 13. Installing pgcrypto is no longer required for versions 13+.
1 parent 790fd1a commit 7704c22

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

crates/arroyo/src/main.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,24 @@ async fn migrate(wait: Option<u32>) -> anyhow::Result<()> {
382382
// make compatible with lower version PG (i.g. 12.16) which not support function
383383
// gen_random_uuid by default.
384384
client
385-
.batch_execute("CREATE EXTENSION IF NOT EXISTS pgcrypto;")
385+
.batch_execute(
386+
r#"
387+
DO $$
388+
BEGIN
389+
IF NOT EXISTS (
390+
SELECT 1
391+
FROM pg_proc
392+
WHERE proname = 'gen_random_uuid'
393+
) THEN
394+
CREATE EXTENSION IF NOT EXISTS pgcrypto;
395+
END IF;
396+
END $$;
397+
"#,
398+
)
386399
.await
387400
.map_err(|e| {
388401
anyhow!(
389-
"Failed to create extension pgcrypto on {:?}: {:?}",
402+
"Failed to verify or install UUID support on {:?}: {:?}",
390403
config().database.postgres,
391404
e
392405
)

0 commit comments

Comments
 (0)