Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-hills-earn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix Fixed permissions in test db setup script (grant CREATEROLE and repair leftover NOLOGIN pgtdbuser for pgtestdb)
12 changes: 12 additions & 0 deletions core/scripts/setup_testdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading