Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for local postgres #2442

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
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
16 changes: 13 additions & 3 deletions docs/HOWTO_USE_POSTGRESQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
To use Postgresql, follow these steps:

1. Either install docker (recommended) or postgresql on your machine:
* If you installed docker run the database using: `docker compose up`
* If you installed postgres locally, create the spoke dev database: `psql -c "create database spokedev;"`
* Then create a spoke user to connect to the database with `createuser -P spoke` with password "spoke" (to match the credentials in the .env.example file)
* If you installed docker run the database using: `docker-compose up`
* If you installed postgres locally (or if you already have a local installation of postgres), create the spoke dev database: `psql -c "create database spokedev;"`
* Then create a spoke user to connect to the database with `psql -d spokedev -c "create user spoke with password 'spoke';"` (to match the credentials in the .env.example file)
* Grant permissions to the new Spoke user:
* `psql -d spokedev -c "GRANT ALL PRIVILEGES ON DATABASE spokedev TO spoke;"`
* `psql -d spokedev -c "GRANT ALL PRIVILEGES ON schema public TO spoke;"`
* Also run the commands from `./dev-tools/create-test-database`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tool won't work for local pg because its set up for docker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'm not saying to run the script directly but to manually run the commands to create a test database instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see. I would instead have you place those instructions directly in the document (minus the docker stuff). I can see new devs getting confused like I did.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the explanation, hopefully this is more clear!

```
psql -d spokedev
CREATE DATABASE spoke_test;
CREATE USER spoke_test WITH PASSWORD 'spoke_test';
GRANT ALL PRIVILEGES ON DATABASE spoke_test TO spoke_test;
```
1. In `.env` set `DB_TYPE=pg`. (Otherwise, you will use sqlite.)
2. Set `DB_PORT=5432`, which is the default port for Postgres.

Expand Down
Loading