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

allow postgresql to load env variables instead of requireing connection string #34

Open
odama626 opened this issue Nov 5, 2023 · 6 comments

Comments

@odama626
Copy link

odama626 commented Nov 5, 2023

No description provided.

@JAForbes
Copy link
Owner

JAForbes commented Nov 5, 2023

@odama626 pgmg are you looking for similar behaviour to psql, e.g. supporting:

  • PGDATABASE
  • PGHOST
  • PGPORT
  • PGUSER

@odama626
Copy link
Author

odama626 commented Nov 5, 2023

Yeah, running postgresjs() with no args does this

@JAForbes
Copy link
Owner

JAForbes commented Nov 5, 2023

I may add this so I'll keep it open, but my current thinking is not to.

It's cool that postgres.js does it, but I don't really see the merit in it for pgmg. You can just set an env variable to the connection string and then use pgmg $URL. I'd rather have one way of doing things than have parity with psql/postgres.js' approach.

@odama626
Copy link
Author

odama626 commented Nov 6, 2023

Yeah, I ended up having to rewrite how I was handling env variables when I was working on going to prod,

I think it would be really easy to add this in, if you only get 1 arg just treat it as a migration file.

Currently there isnt really a good way to do migrations locally either since I am using env files to set my variables locally so I have to load them in with bash first

So far I am really enjoying the simplicity of pgmg otherwise though

@JAForbes
Copy link
Owner

JAForbes commented Nov 6, 2023

That's great to hear, I'll think about it, but after many years of only using connection strings, I don't see any advantage in having separate PGHOST, PGPORT variables etc. Connection strings are so useful, they give you a lot of power.

And yes it would be easy to add, but most things are. I think it is the little conveniences we add along the way that lead to complexity down the line.

For variables, e.g. role passwords etc, I just use dotenv in the migration file. Would that work for you?

@JAForbes
Copy link
Owner

JAForbes commented Nov 6, 2023

Also for local dev workflows, in upcoming release there'll be big improvements there.

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

No branches or pull requests

2 participants