Skip to content

Commit db0799b

Browse files
committed
fix(link): take url as string arg
1 parent 85eee76 commit db0799b

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

cmd/link.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
11
package cmd
22

33
import (
4-
"errors"
5-
"fmt"
6-
74
"github.com/spf13/cobra"
85
"github.com/supabase/cli/internal/link"
96
)
107

118
var (
12-
useUrl bool
9+
deployDbUrl string
1310

1411
linkCmd = &cobra.Command{
1512
Use: "link",
1613
Short: "Link the current project to a remote deploy database.",
1714
RunE: func(cmd *cobra.Command, args []string) error {
18-
if useUrl {
19-
var deployDbUrl string
20-
fmt.Scanln(&deployDbUrl)
21-
if len(deployDbUrl) == 0 {
22-
return errors.New("Error on `supabase link`: URL is empty.")
23-
}
24-
25-
return link.Link(deployDbUrl)
26-
}
27-
28-
return errors.New("Use `--url` to pass the deploy database URL to link to.")
15+
return link.Link(deployDbUrl)
2916
},
3017
}
3118
)
3219

3320
func init() {
3421
linkCmd.Flags().
35-
BoolVar(&useUrl, "url", false, "Accept Postgres connection string of the deploy database from standard input.")
22+
StringVar(&deployDbUrl, "url", "", "Postgres connection string of the deploy database.")
23+
cobra.CheckErr(linkCmd.MarkFlagRequired("url"))
3624

3725
rootCmd.AddCommand(linkCmd)
3826
}

examples/tour/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ supabase init
2525
This will create a `supabase` directory which is managed by the CLI. Then we need to link the current project with the deploy database. Use the connection string from your Supabase project here.
2626

2727
```sh
28-
supabase link --url <<< 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'
28+
supabase link --url 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'
2929
```
3030

3131
Why do we need to do this? Because if we want to manage a database with a migration tool, we need a _baseline_ where both the migration tool and the database have consistent schemas. `supabase link` does this synchronization between the two.

0 commit comments

Comments
 (0)