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

Postgres: use psql instead of postgres CLI to load the initialScript #63

Closed
shivaraj-bh opened this issue Nov 28, 2023 · 0 comments · Fixed by #66
Closed

Postgres: use psql instead of postgres CLI to load the initialScript #63

shivaraj-bh opened this issue Nov 28, 2023 · 0 comments · Fixed by #66

Comments

@shivaraj-bh
Copy link
Member

shivaraj-bh commented Nov 28, 2023

SQL dumps can have multi-line queries, for instance:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  email VARCHAR(50) NOT NULL UNIQUE
);

In such a case using postgres -E as here will error out because the command expects single line statements.

The solution to which can be postgres -j -E, but I think it is ideal to load the dumps with psql command instead -- as suggested in the postgres official doc.

Proposed solution

Context: The reason for using postgres is that we won't have the postgres server running while the init script is running.

We can run initialScript.before using postgres (as init script, before starting the server) and have initialScript.after run with psql as a process dependent on the postgres server.

Ideally, to keep things uniform, I would prefer running all init SQL commands via psql.

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 a pull request may close this issue.

1 participant