Skip to content

Commit 67b091d

Browse files
matiwinnetouclaude
andcommitted
fix: grant schema privileges to database user for PostgreSQL 15+
PostgreSQL 15+ changed the default security model where the PUBLIC role no longer has CREATE privilege on the public schema. This caused Flyway migrations to fail during integration tests with "permission denied for schema public" errors. Added explicit GRANT commands to: - Grant all privileges on the public schema to the database user - Grant privileges on all existing tables in the schema - Set default privileges for future tables created in the schema This fix ensures the yaci-indexer can successfully run database migrations during Docker container initialization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8fc598c commit 67b091d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docker/dockerfiles/postgres/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ create_database_and_user() {
125125
sudo -u postgres "$PG_BIN/psql" -U postgres -p "$DB_PORT" -c "GRANT ALL PRIVILEGES ON DATABASE \"$DB_NAME\" to \"$DB_USER\";" > /dev/null
126126
fi
127127

128+
# Grant schema privileges (required for PostgreSQL 15+)
129+
echo "Granting schema privileges..."
130+
sudo -u postgres "$PG_BIN/psql" -U postgres -p "$DB_PORT" -d "$DB_NAME" -c "GRANT ALL ON SCHEMA public TO \"$DB_USER\";" > /dev/null
131+
sudo -u postgres "$PG_BIN/psql" -U postgres -p "$DB_PORT" -d "$DB_NAME" -c "GRANT ALL ON ALL TABLES IN SCHEMA public TO \"$DB_USER\";" > /dev/null
132+
sudo -u postgres "$PG_BIN/psql" -U postgres -p "$DB_PORT" -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO \"$DB_USER\";" > /dev/null
133+
128134
echo "User configured"
129135
}
130136

0 commit comments

Comments
 (0)