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

supabase / cli / 16976524820

14 Aug 2025 08:57PM UTC coverage: 54.808% (-0.5%) from 55.271%
16976524820

Pull #3969

github

web-flow
Merge 419dd46ad into b3d509dd5
Pull Request #3969: feat: generate jwt tokens from signing key

11 of 13 new or added lines in 1 file covered. (84.62%)

391 existing lines in 14 files now uncovered.

6196 of 11305 relevant lines covered (54.81%)

6.09 hits per line

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

0.0
/internal/db/diff/pgschema.go
1
package diff
2

3
import (
4
        "context"
5
        "database/sql"
6
        "fmt"
7
        "strings"
8

9
        "github.com/go-errors/errors"
10
        pgschema "github.com/stripe/pg-schema-diff/pkg/diff"
11
)
12

13
func DiffPgSchema(ctx context.Context, source, target string, schema []string) (string, error) {
×
14
        dbSrc, err := sql.Open("pgx", source)
×
15
        if err != nil {
×
16
                return "", errors.Errorf("failed to open source database: %w", err)
×
17
        }
×
18
        defer dbSrc.Close()
×
19
        dbDst, err := sql.Open("pgx", target)
×
20
        if err != nil {
×
21
                return "", errors.Errorf("failed to open target database: %w", err)
×
22
        }
×
23
        defer dbDst.Close()
×
24
        // Generate DDL based on schema plan
×
25
        opts := []pgschema.PlanOpt{pgschema.WithDoNotValidatePlan()}
×
26
        if len(schema) > 0 {
×
27
                opts = append(opts, pgschema.WithIncludeSchemas(schema...))
×
28
        } else {
×
29
                opts = append(opts,
×
30
                        pgschema.WithExcludeSchemas(managedSchemas...),
×
31
                        pgschema.WithExcludeSchemas(
×
32
                                "topology", // unsupported due to views
×
33
                                "realtime", // unsupported due to partitioned table
×
34
                                "storage",  // unsupported due to unique index
×
35
                        ),
×
36
                )
×
37
        }
×
38
        plan, err := pgschema.Generate(
×
39
                ctx,
×
40
                pgschema.DBSchemaSource(dbSrc),
×
UNCOV
41
                pgschema.DBSchemaSource(dbDst),
×
42
                opts...,
×
UNCOV
43
        )
×
UNCOV
44
        if err != nil {
×
UNCOV
45
                return "", errors.Errorf("failed to generate plan: %w", err)
×
UNCOV
46
        }
×
UNCOV
47
        var lines []string
×
UNCOV
48
        for _, stat := range plan.Statements {
×
UNCOV
49
                for _, harzard := range stat.Hazards {
×
UNCOV
50
                        lines = append(lines, fmt.Sprintf("-- %s", harzard))
×
UNCOV
51
                }
×
UNCOV
52
                lines = append(lines, fmt.Sprintf("%s;\n", stat.DDL))
×
53
        }
UNCOV
54
        return fmt.Sprintln(strings.Join(lines, "\n")), nil
×
55
}
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

© 2025 Coveralls, Inc