Skip to content

Fix init script for PostgreSQL 18 compatibility#3

Open
leroytang-redis wants to merge 1 commit intoRedislabs-Solution-Architects:mainfrom
leroytang-redis:fix/postgres-18-init-script
Open

Fix init script for PostgreSQL 18 compatibility#3
leroytang-redis wants to merge 1 commit intoRedislabs-Solution-Architects:mainfrom
leroytang-redis:fix/postgres-18-init-script

Conversation

@leroytang-redis
Copy link
Copy Markdown

Fix PostgreSQL 18 Compatibility Issue

Problem

The initialization script fails on PostgreSQL 18 because it uses a hardcoded path to postgresql.conf that doesn't exist:

PGDATA=/var/lib/postgresql/data
echo "wal_level = logical" >> $PGDATA/postgresql.conf

PostgreSQL 18 uses /var/lib/postgresql/18/docker instead of /var/lib/postgresql/data, causing the script to fail with:

/var/lib/postgresql/data/postgresql.conf: No such file or directory

This prevents the Chinook database from being initialized and populated.

Solution

Use the container's $PGDATA environment variable instead of hardcoding the path. This makes the script compatible with all PostgreSQL versions.

Testing

Tested with:

  • PostgreSQL 18 (latest) ✅
  • Tables are now properly created and populated on first run

Changes

  • Modified scripts/init_docker-postgres.sh to use $PGDATA environment variable

The hardcoded PGDATA path (/var/lib/postgresql/data) doesn't work
with PostgreSQL 18, which uses /var/lib/postgresql/18/docker.

This fix uses the container's $PGDATA environment variable instead,
making it compatible with all PostgreSQL versions.
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.

1 participant