Skip to content

Obtaining DB_URL from the CLI #2964

Closed

Description

@scherven

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!

Activity

  1. sweatybridge commented on Dec 11, 2024

    @sweatybridge
    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.

  2. yaten2302 commented on Dec 20, 2024

    @yaten2302
    Contributor

    @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 👀 ?

  3. sweatybridge commented on Dec 20, 2024

    @sweatybridge
    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.

  4. yaten2302 commented on Dec 20, 2024

    @yaten2302
    Contributor

    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 👍

  5. yaten2302 commented on Dec 24, 2024

    @yaten2302
    Contributor

    Any update on this @sweatybridge :)

  6. sweatybridge commented on Dec 24, 2024

    @sweatybridge
    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.

  7. yaten2302 commented on Dec 25, 2024

    @yaten2302
    Contributor

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

  8. yaten2302 commented on Dec 25, 2024

    @yaten2302
    Contributor

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

  9. yaten2302 commented on Dec 29, 2024

    @yaten2302
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions