@@ -9,14 +9,11 @@ import (
99 "github.com/cenkalti/backoff/v4"
1010 "github.com/go-errors/errors"
1111 "github.com/jackc/pgconn"
12- "github.com/jackc/pgx/v4"
1312 "github.com/spf13/afero"
1413 "github.com/spf13/viper"
1514 "github.com/supabase/cli/internal/db/pull"
1615 "github.com/supabase/cli/internal/link"
1716 "github.com/supabase/cli/internal/login"
18- "github.com/supabase/cli/internal/migration/new"
19- "github.com/supabase/cli/internal/migration/repair"
2017 "github.com/supabase/cli/internal/projects/apiKeys"
2118 "github.com/supabase/cli/internal/utils"
2219 "github.com/supabase/cli/internal/utils/flags"
@@ -98,26 +95,12 @@ func linkProject(ctx context.Context, fsys afero.Fs) error {
9895 return utils .WriteFile (utils .ProjectRefPath , []byte (flags .ProjectRef ), fsys )
9996}
10097
101- func dumpRemoteSchema (ctx context.Context , config pgconn.Config , fsys afero.Fs , options ... func (* pgx.ConnConfig )) error {
102- // 1. Check postgres connection
103- conn , err := utils .ConnectByConfig (ctx , config , options ... )
104- if err != nil {
105- return err
106- }
107- defer conn .Close (context .Background ())
108- // 2. Pull schema
109- timestamp := utils .GetCurrentTimestamp ()
110- path := new .GetMigrationPath (timestamp , "remote_schema" )
111- // Ignore schemas flag when working on the initial pull
112- if err = pull .CloneRemoteSchema (ctx , path , config , fsys ); err != nil {
113- return err
114- }
115- // 3. Insert a row to `schema_migrations`
116- fmt .Fprintln (os .Stderr , "Schema written to " + utils .Bold (path ))
117- if shouldUpdate , err := utils .NewConsole ().PromptYesNo (ctx , "Update remote migration history table?" , true ); err != nil {
98+ func dumpRemoteSchema (ctx context.Context , config pgconn.Config , fsys afero.Fs ) error {
99+ schemaPath := filepath .Join (utils .SchemasDir , "remote.sql" )
100+ utils .Config .Db .Migrations .SchemaPaths = append (utils .Config .Db .Migrations .SchemaPaths , filepath .ToSlash (schemaPath ))
101+ if err := pull .CloneRemoteSchema (ctx , schemaPath , config , fsys ); err != nil {
118102 return err
119- } else if shouldUpdate {
120- return repair .UpdateMigrationTable (ctx , conn , []string {timestamp }, repair .Applied , true , fsys )
121103 }
104+ fmt .Fprintln (os .Stderr , "Schema written to " + utils .Bold (schemaPath ))
122105 return nil
123106}
0 commit comments