Skip to content

chore(coderd/database/gen/dump): add optional DB_DUMP_CONNECTION_URL #16243

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

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

mafredri
Copy link
Member

This change allows the DB dump to be performed without Docker, BYODB.

@mafredri mafredri self-assigned this Jan 23, 2025
@mafredri mafredri requested review from johnstcn and mtojek January 23, 2025 16:11
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Great idea to include erro context in panic(err).

Comment on lines +75 to +79
- PostgreSQL 13 (optional if Docker is available)
- *Note*: If you are using Docker, you can skip this step
- on macOS, run `brew install postgresql@13` and `brew services start postgresql@13`
- To enable schema generation with non-containerized PostgreSQL, set the following environment variable:
- `export DB_DUMP_CONNECTION_URL="postgres://postgres@localhost:5432/postgres?password=postgres&sslmode=disable"`
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a warning note regarding pg_dump version compatibility:

DB_DUMP_CONNECTION_URL='postgresql://user:pass@ds918.home:5433/coder_tmp?sslmode=disable' make gen
pg_dump: error: server version: 16.2 (Debian 16.2-1.pgdg120+2); pg_dump version: 13.18
pg_dump: error: aborting because of server version mismatch
panic: dump schema failed: exit status 1

goroutine 1 [running]:
main.main()
        /Users/cian/src/coder/coder/coderd/database/gen/dump/main.go:70 +0x354
exit status 2
make: *** [Makefile:618: coderd/database/dump.sql] Error 1

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is an unlikely scenario, you can use pg_dump@16 with postgresql@13 but not vice-versa as you saw here. Since we're advising to use an older postgresql server here, you'd really have to make an effort to use an even older pg_dump 😄

@mafredri mafredri merged commit f27e73d into main Jan 23, 2025
35 checks passed
@mafredri mafredri deleted the mafredri/chore-allow-custom-db-dump-url branch January 23, 2025 16:53
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants