Fix getting-started example: broken database setup#85
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes the examples/getting-started manual tutorial flow by aligning PostgreSQL initialization, server configuration, and helper scripts so the database is actually initialized and the server can connect with sensible defaults.
Changes:
- Ensures the getting-started Postgres container executes
init.sqlon first startup and simplifies healthcheck/networking. - Aligns getting-started schema/config/scripts around the
Messagetable name and updated publication/slot names. - Adds a default
POSTGRES_PASSWORDfor the server config and exports it instart-server.sh.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/getting-started/server-config.yaml | Adds default DB password and updates table name / Cypher labels to Message. |
| examples/getting-started/scripts/start-server.sh | Exports a default POSTGRES_PASSWORD before launching the server. |
| examples/getting-started/scripts/setup-database.sh | Updates verification query to reference "Message". |
| examples/getting-started/scripts/run-end-to-end.sh | Updates inline schema/setup SQL to use "Message" consistently. |
| examples/getting-started/scripts/delete-message.sh | Updates SQL statements to reference "Message". |
| examples/getting-started/scripts/add-message.sh | Updates SQL statement to reference "Message". |
| examples/getting-started/database/init.sql | Updates schema columns to lowercase + adjusts publication/slot names for getting-started. |
| examples/getting-started/database/docker-compose.yml | Mounts init.sql into /docker-entrypoint-initdb.d/, switches healthcheck user, removes external network requirement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - "${POSTGRES_HOST_PORT:-5432}:5432" | ||
| volumes: | ||
| - getting_started_postgres_data:/var/lib/postgresql/data | ||
| - ./init.sql:/docker-entrypoint-initdb.d/init.sql |
There was a problem hiding this comment.
Do we need this if the user is going to run docker exec -i getting-started-postgres psql -U postgres -d getting_started < examples/getting-started/database/init.sql?
See https://drasi.io/drasi-server/getting-started/#initialize-the-database
| BEGIN | ||
| IF NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'drasi_slot') THEN | ||
| PERFORM pg_create_logical_replication_slot('drasi_slot', 'pgoutput'); | ||
| IF NOT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'drasi_getting_started_slot') THEN |
There was a problem hiding this comment.
When we use the wizard to create the server config yaml file, it uses drasi_slot instead of drasi_getting_started_slot. The users will use this yaml file instead of server-config.yaml.
I suggest we update server-config.yaml to use drasi_slot so that it is consistent with the output from the wizard
Problem
The getting-started example's manual tutorial flow was completely broken due to multiple inconsistencies between the database setup and server configuration:
init.sqlnever executed —docker-compose.ymldidn't mount it into/docker-entrypoint-initdb.d/, so the database was never initializedserver-config.yamlused${POSTGRES_PASSWORD}with no fallback, resolving to emptyinit.sqlcreateddrasi_pub/drasi_slotbut the server config and scripts expecteddrasi_getting_started_pub/drasi_getting_started_slotinit.sqlused PascalCase ("Message","MessageId") but the server config and shell scripts used lowercase (message,messageid)docker-compose.ymlrequired a pre-existingdrasi-networkthatsetup-database.shnever createdstart-server.shdidn't setPOSTGRES_PASSWORDChanges
docker-compose.ymlinit.sqlinto/docker-entrypoint-initdb.d/so the DB gets initializedpostgressuperuser in healthcheck (guaranteed to exist)drasi-networkrequirement (not needed; server connects via localhost)init.sqldrasi_pub→drasi_getting_started_pubdrasi_slot→drasi_getting_started_slotserver-config.yaml${POSTGRES_PASSWORD:-drasi_password}start-server.shPOSTGRES_PASSWORD=drasi_passwordas default before launching serverNot affected
run-end-to-end.shand CI workflows do their own inline schema setup, so they are unaffected by these changes