Skip to content

Commit 99d45d4

Browse files
authored
fix: skip config diff to reduce output noise (#4036)
1 parent 2245fd2 commit 99d45d4

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

internal/link/link.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ import (
1919
"github.com/supabase/cli/pkg/api"
2020
"github.com/supabase/cli/pkg/cast"
2121
cliConfig "github.com/supabase/cli/pkg/config"
22-
"github.com/supabase/cli/pkg/diff"
2322
"github.com/supabase/cli/pkg/migration"
2423
)
2524

2625
func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
27-
copy := utils.Config.Clone()
28-
original, err := cliConfig.ToTomlBytes(copy)
29-
if err != nil {
30-
fmt.Fprintln(utils.GetDebugLogger(), err)
31-
}
32-
26+
majorVersion := utils.Config.Db.MajorVersion
3327
if err := checkRemoteProjectStatus(ctx, projectRef, fsys); err != nil {
3428
return err
3529
}
@@ -54,14 +48,12 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(
5448
fmt.Fprintln(os.Stdout, "Finished "+utils.Aqua("supabase link")+".")
5549

5650
// 4. Suggest config update
57-
updated, err := cliConfig.ToTomlBytes(utils.Config.Clone())
58-
if err != nil {
59-
fmt.Fprintln(utils.GetDebugLogger(), err)
60-
}
61-
62-
if lineDiff := diff.Diff(utils.ConfigPath, original, projectRef, updated); len(lineDiff) > 0 {
63-
fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Local config differs from linked project. Try updating", utils.Bold(utils.ConfigPath))
64-
fmt.Println(string(lineDiff))
51+
if utils.Config.Db.MajorVersion != majorVersion {
52+
fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Local database version differs from the linked project.")
53+
fmt.Fprintf(os.Stderr, `Update your %s to fix it:
54+
[db]
55+
major_version = %d
56+
`, utils.Bold(utils.ConfigPath), utils.Config.Db.MajorVersion)
6557
}
6658
return nil
6759
}

pkg/pgxv5/connect.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ func Connect(ctx context.Context, connString string, options ...func(*pgx.ConnCo
2424
return nil, errors.Errorf("failed to parse connection string: %w", err)
2525
}
2626
config.OnNotice = func(pc *pgconn.PgConn, n *pgconn.Notice) {
27-
fmt.Fprintf(os.Stderr, "%s (%s): %s\n", n.Severity, n.Code, n.Message)
27+
if !shouldIgnore(n.Message) {
28+
fmt.Fprintf(os.Stderr, "%s (%s): %s\n", n.Severity, n.Code, n.Message)
29+
}
2830
}
2931
if strings.HasPrefix(config.User, CLI_LOGIN_ROLE) {
3032
config.AfterConnect = func(ctx context.Context, pgconn *pgconn.PgConn) error {
@@ -42,3 +44,9 @@ func Connect(ctx context.Context, connString string, options ...func(*pgx.ConnCo
4244
}
4345
return conn, nil
4446
}
47+
48+
func shouldIgnore(msg string) bool {
49+
return strings.Contains(msg, `schema "supabase_migrations" already exists`) ||
50+
strings.Contains(msg, `relation "schema_migrations" already exists`) ||
51+
strings.Contains(msg, `relation "seed_files" already exists`)
52+
}

0 commit comments

Comments
 (0)