Skip to content

feat: bump pgstac database up to postgresql 15#70

Merged
hrodmn merged 1 commit intomainfrom
feat/postgres-15
Nov 3, 2025
Merged

feat: bump pgstac database up to postgresql 15#70
hrodmn merged 1 commit intomainfrom
feat/postgres-15

Conversation

@hrodmn
Copy link
Collaborator

@hrodmn hrodmn commented Oct 10, 2025

This is the first of three sequential upgrades we need to perform on the pgstac RDS database instances.

Prerequisite manual database update

For each RDS database instance, do the following before attempting to upgrade the PostgreSQL version:

  1. Go to secrets manager and find the secret with the root user credentials

  2. Connect to the pgbouncer EC2 instance corresponding to the database

  3. Install postgresql-client-14

sudo apt update && sudo apt install postgresql-client-14
  1. Set environment variables to connect to the PostgreSQL database as the root user (postgres)
# these are constants
export PGPORT=5432
export PGDATABASE=pgstac
export PGUSER=postgres

# these are variable
export PGPASSWORD=
export PGHOST=
  1. Connect to the database and update the function signature for the pgstac functions so that the search_path includes the public schema
psql  -c "

DO $$
DECLARE
    -- Variable to hold the full, unambiguous signature of each function
    func_signature text;
BEGIN
    -- Loop through all functions in the 'pgstac' schema
    FOR func_signature IN
        SELECT
            -- This casts the function's OID to its formal signature,
            -- e.g., 'pgstac.collection_geom(jsonb)'
            p.oid::regprocedure::text
        FROM
            pg_proc p
        JOIN
            pg_namespace n ON p.pronamespace = n.oid
        WHERE
            n.nspname = 'pgstac' AND p.prokind = 'f' -- Ensures we only alter actual functions
    LOOP
        -- Build and execute the ALTER FUNCTION command using the full signature
        RAISE NOTICE 'Hardening function: %', func_signature;
        EXECUTE format(
            'ALTER FUNCTION %s SET search_path = pgstac, public, pg_catalog;',
            func_signature
        );
    END LOOP;
    RAISE NOTICE 'All functions in pgstac schema have been updated.';
END;
$$;
"

@hrodmn hrodmn requested a review from jjfrench October 10, 2025 15:00
@hrodmn hrodmn self-assigned this Oct 10, 2025
Copy link
Member

@jjfrench jjfrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there issues with the branch trying to deploy before attempting these steps?

@hrodmn
Copy link
Collaborator Author

hrodmn commented Nov 3, 2025

Are there issues with the branch trying to deploy before attempting these steps?

I'm not sure I understand the question - I was able to deploy these changes to the test deployment after modifying the pgstac functions' search_path as described above.

@jjfrench
Copy link
Member

jjfrench commented Nov 3, 2025

Doesn't the branch deploy to test before it's merged? I was just wondering if the steps above were done before the branch deployment or if there were issues if the branch deployment had issues if the steps were done after the merge

@hrodmn
Copy link
Collaborator Author

hrodmn commented Nov 3, 2025

Doesn't the branch deploy to test before it's merged?

No we don't have any automatic deployments set up - everything goes through workflow dispatch!

@hrodmn hrodmn merged commit 19b6b2e into main Nov 3, 2025
3 of 6 checks passed
@hrodmn hrodmn deleted the feat/postgres-15 branch November 3, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants