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

Obtaining DB_URL from the CLI #2964

Open
Innoviox opened this issue Dec 10, 2024 · 9 comments · May be fixed by #2996
Open

Obtaining DB_URL from the CLI #2964

Innoviox opened this issue Dec 10, 2024 · 9 comments · May be fixed by #2996
Labels
enhancement New feature or request

Comments

@Innoviox
Copy link

Is your feature request related to a problem? Please describe.
I am attempting to set up branch previews (similar to Vercel) in railway. To do this, I need to update some environment variables on the railway side, including SUPABASE_DB_URL.

Describe the solution you'd like
I'd like to be able to run some supabase CLI command to obtain the DB_URl automatically, so I don't have to add it manually as a variable whenever I make a new branch. However, I cannot find a CLI command that will do this. gen keys gives me the password but not the user, the port, the database, or the host. branches get has the user, port, and host, but these conflict with the information shown in my dashboard. (I assume the database is always postgres?)

Describe alternatives you've considered
I've looked in the docs for the CLI and the javascript library, and neither of them seems to provide the database url. Any help is appreciated!

@sweatybridge sweatybridge added the enhancement New feature or request label Dec 11, 2024
@sweatybridge
Copy link
Contributor

Hi @Innoviox, thanks for the suggestion.

We can definitely make branches get more useful by adding a --output env flag to format the output. We already have a list of envs that users typically want exposed. These include both pooling (shown in cli) and non-pooling (shown on dashboard) db urls.

I will probably have time to look into this early 2025.

@yaten2302
Copy link

@sweatybridge , if this issue is open, then may I work on this issue? I've a lot of experience in Go and have previously contributed to Keploy, Meshery(both CNCF projects) and Taipy.
May I work on this issue, if it's open to all 👀 ?

@sweatybridge
Copy link
Contributor

@yaten2302 sure thing. We have some examples of using the output flag in status command.

Feel free to tag me if you have any questions or want a review.

@yaten2302
Copy link

Thanks for your suggestions @sweatybridge!
I've a few doubts, regarding the same, could you please help me with those:

  1. Firstly, what exactly we're doing here is that, currently there's no command to export the supabase DB_URL from the .env file and we need to add a flag --output env to the existing command - branches get?
  2. As mentioned by you in this comment, the one's with pooling are shown in cli and ones with non_pooling, are shown on the supabase dashboard. So, I need to export this - POSTGRES_URL = "POSTGRES_URL", to the cli, am I right? Is there anything else also that needs to be exported?

And yes, I'll take help from the status command to check how to add a new flag to a command, which you mentioned in your previous comment 👍

@yaten2302
Copy link

Any update on this @sweatybridge :)

@sweatybridge
Copy link
Contributor

Currently branches get command prints the database connection details, but not the full connection string. The code for building the full connection string is available in bootstrap command. Also in the bootstrap command, we expose both pooling and non pooling url.

So there are a few tasks I would suggest as next steps

  1. Add --output flag to branches get command while keeping all existing output fields. For eg, the current table output includes db user field, so specifying --output env should also include a POSTGRES_USER env var.

  2. Next, we can add postgres_url and postgres_url_non_pooling to the env output. The code for this can be reused from bootstrap command.

Hope it clarifies.

@yaten2302
Copy link

Got it @sweatybridge 👍
I've understood the workflow, working on it, I'll create a draft PR soon!!
Thanks

@yaten2302
Copy link

@sweatybridge I've created a draft PR for this issue 👍

@yaten2302
Copy link

Hey @sweatybridge , could you please guide regarding the PR, whenever you get time :)
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants