File tree Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,13 @@ import (
14
14
var ctx = context .Background ()
15
15
16
16
func Run () error {
17
- url := os .Getenv ( "SUPABASE_REMOTE_DB_URL " )
18
- if url == "" {
17
+ urlBytes , err := os .ReadFile ( "supabase/.temp/remote-db-url " )
18
+ if errors . Is ( err , os . ErrNotExist ) {
19
19
return errors .New ("Remote database is not set. Run " + utils .Aqua ("supabase db remote set" ) + " first." )
20
+ } else if err != nil {
21
+ return err
20
22
}
23
+ url := string (urlBytes )
21
24
22
25
conn , err := pgx .Connect (ctx , url )
23
26
if err != nil {
Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ func Run() error {
35
35
}
36
36
}
37
37
38
- url := os .Getenv ( "SUPABASE_REMOTE_DB_URL " )
39
- if url == "" {
38
+ urlBytes , err := os .ReadFile ( "supabase/.temp/remote-db-url " )
39
+ if errors . Is ( err , os . ErrNotExist ) {
40
40
return errors .New ("Remote database is not set. Run " + utils .Aqua ("supabase db remote set" ) + " first." )
41
+ } else if err != nil {
42
+ return err
41
43
}
44
+ url := string (urlBytes )
42
45
43
46
s := spinner .NewModel ()
44
47
s .Spinner = spinner .Dot
Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ func Run() error {
35
35
}
36
36
}
37
37
38
- url := os .Getenv ( "SUPABASE_REMOTE_DB_URL " )
39
- if url == "" {
38
+ urlBytes , err := os .ReadFile ( "supabase/.temp/remote-db-url " )
39
+ if errors . Is ( err , os . ErrNotExist ) {
40
40
return errors .New ("Remote database is not set. Run " + utils .Aqua ("supabase db remote set" ) + " first." )
41
+ } else if err != nil {
42
+ return err
41
43
}
44
+ url := string (urlBytes )
42
45
43
46
s := spinner .NewModel ()
44
47
s .Spinner = spinner .Dot
Original file line number Diff line number Diff line change @@ -110,7 +110,10 @@ CREATE TABLE supabase_migrations.schema_migrations (version text NOT NULL PRIMAR
110
110
rows .Close ()
111
111
112
112
// 3. Write .env
113
- if err := os .WriteFile ("supabase/.env" , []byte ("SUPABASE_REMOTE_DB_URL=" + url ), 0644 ); err != nil {
113
+ if err := utils .MkdirIfNotExist ("supabase/.temp" ); err != nil {
114
+ return err
115
+ }
116
+ if err := os .WriteFile ("supabase/.temp/remote-db-url" , []byte (url ), 0600 ); err != nil {
114
117
return err
115
118
}
116
119
Original file line number Diff line number Diff line change 1
1
# Supabase
2
2
**/supabase/.branches
3
3
**/supabase/.temp
4
- **/supabase/.env
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "github.com/joho/godotenv"
5
4
"github.com/supabase/cli/cmd"
6
5
)
7
6
8
7
func main () {
9
- _ = godotenv .Load ("supabase/.env" )
10
-
11
8
cmd .Execute ()
12
9
}
You can’t perform that action at this time.
0 commit comments