From 558ce047d8f397806898bab6e4cd20dc3bd9b367 Mon Sep 17 00:00:00 2001 From: Steve Ellis Date: Thu, 25 Jun 2026 18:41:23 -0400 Subject: [PATCH] fix(setup_testdb): grant CREATEROLE for pgtestdb The heavyweight migration tests now use pgtestdb, which provisions an isolated role (pgtdbuser) per test run. The dev user created by this script only had CREATEDB, so those tests failed with: could not create pgtestdb user: failed to create role pgtdbuser: ERROR: permission denied to create role (SQLSTATE 42501) Grant CREATEROLE alongside the existing CREATEDB so a fresh setup works. Co-Authored-By: Claude Opus 4.8 (1M context) fix test db setup to ensure you can create roles --- .changeset/small-hills-earn.md | 5 +++++ core/scripts/setup_testdb.sh | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .changeset/small-hills-earn.md diff --git a/.changeset/small-hills-earn.md b/.changeset/small-hills-earn.md new file mode 100644 index 00000000000..70fc3fad3b5 --- /dev/null +++ b/.changeset/small-hills-earn.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#bugfix Fixed permissions in test db setup script (grant CREATEROLE and repair leftover NOLOGIN pgtdbuser for pgtestdb) diff --git a/core/scripts/setup_testdb.sh b/core/scripts/setup_testdb.sh index cdaf3547ece..e3a80a1b473 100755 --- a/core/scripts/setup_testdb.sh +++ b/core/scripts/setup_testdb.sh @@ -28,6 +28,18 @@ WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$database')\gexec ALTER DATABASE $database OWNER TO $username; GRANT ALL PRIVILEGES ON DATABASE "$database" TO "$username"; ALTER USER $username CREATEDB; +-- CREATEROLE is required by pgtestdb, which provisions an isolated role (pgtdbuser) per test run. +ALTER USER $username CREATEROLE; + +-- Repair a leftover pgtdbuser from an earlier run that lacks LOGIN. pgtestdb only sets +-- LOGIN when it first creates the role, so a pre-existing NOLOGIN role stays broken and +-- tests fail with: role "pgtdbuser" is not permitted to log in (SQLSTATE 28000). +DO \$\$ +BEGIN + IF EXISTS (SELECT FROM pg_roles WHERE rolname = 'pgtdbuser' AND NOT rolcanlogin) THEN + ALTER ROLE pgtdbuser WITH LOGIN PASSWORD 'pgtdbpass'; + END IF; +END \$\$; EOF