• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 8998220942

08 May 2024 07:49AM UTC coverage: 57.468% (+0.003%) from 57.465%
8998220942

push

github

web-flow
chore: clean up db pull implementation (#2175)

* chore: clean up db pull implementation

* chore: update unit tests

0 of 4 new or added lines in 2 files covered. (0.0%)

4 existing lines in 3 files now uncovered.

6383 of 11107 relevant lines covered (57.47%)

659.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/db/remote/changes/changes.go
1
package changes
2

3
import (
4
        "context"
5
        "io"
6

7
        "github.com/jackc/pgconn"
8
        "github.com/spf13/afero"
9
        "github.com/supabase/cli/internal/db/diff"
10
        "github.com/supabase/cli/internal/db/reset"
11
        "github.com/supabase/cli/internal/utils"
12
)
13

14
var output string
15

16
func Run(ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) error {
×
17
        // Sanity checks.
×
NEW
18
        if err := utils.LoadConfigFS(fsys); err != nil {
×
NEW
19
                return err
×
UNCOV
20
        }
×
21

22
        if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error {
×
23
                return run(p, ctx, schema, config, fsys)
×
24
        }); err != nil {
×
25
                return err
×
26
        }
×
27

28
        return diff.SaveDiff(output, "", fsys)
×
29
}
30

31
func run(p utils.Program, ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) (err error) {
×
32
        // 1. Assert `supabase/migrations` and `schema_migrations` are in sync.
×
33
        w := utils.StatusWriter{Program: p}
×
34
        if len(schema) == 0 {
×
35
                schema, err = loadSchema(ctx, config, w)
×
36
                if err != nil {
×
37
                        return err
×
38
                }
×
39
        }
40

41
        // 2. Diff remote db (source) & shadow db (target) and print it.
42
        output, err = diff.DiffDatabase(ctx, schema, config, w, fsys, diff.DiffSchemaMigra)
×
43
        return err
×
44
}
45

46
func loadSchema(ctx context.Context, config pgconn.Config, w io.Writer) ([]string, error) {
×
47
        conn, err := utils.ConnectByConfigStream(ctx, config, w)
×
48
        if err != nil {
×
49
                return nil, err
×
50
        }
×
51
        defer conn.Close(context.Background())
×
52
        return reset.LoadUserSchemas(ctx, conn)
×
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc