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

supabase / cli / 8665741536

12 Apr 2024 05:19PM UTC coverage: 57.738% (-0.07%) from 57.812%
8665741536

Pull #2138

github

sweatybridge
fix: add schema column to table sizes query
Pull Request #2138: fix: exclude supabase managed schemas from inspect subcommand

2 of 46 new or added lines in 20 files covered. (4.35%)

5 existing lines in 1 file now uncovered.

6376 of 11043 relevant lines covered (57.74%)

662.93 hits per line

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

0.0
/internal/inspect/vacuum_stats/vacuum_stats.go
1
package vacuum_stats
2

3
import (
4
        "context"
5
        "fmt"
6
        "strings"
7

8
        "github.com/go-errors/errors"
9
        "github.com/jackc/pgconn"
10
        "github.com/jackc/pgx/v4"
11
        "github.com/spf13/afero"
12
        "github.com/supabase/cli/internal/db/reset"
13
        "github.com/supabase/cli/internal/inspect"
14
        "github.com/supabase/cli/internal/migration/list"
15
        "github.com/supabase/cli/internal/utils"
16
        "github.com/supabase/cli/internal/utils/pgxv5"
17
)
18

19
type Result struct {
20
        Schema               string
21
        Table                string
22
        Last_vacuum          string
23
        Last_autovacuum      string
24
        Rowcount             string
25
        Dead_rowcount        string
26
        Autovacuum_threshold string
27
        Expect_autovacuum    string
28
}
29

30
func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
×
31
        conn, err := utils.ConnectByConfig(ctx, config, options...)
×
32
        if err != nil {
×
33
                return err
×
34
        }
×
NEW
35
        rows, err := conn.Query(ctx, inspect.VACUUM_STATS_QUERY, reset.LikeEscapeSchema(utils.InternalSchemas))
×
36
        if err != nil {
×
37
                return errors.Errorf("failed to query rows: %w", err)
×
38
        }
×
39
        result, err := pgxv5.CollectRows[Result](rows)
×
40
        if err != nil {
×
41
                return err
×
42
        }
×
43

44
        table := "|Schema|Table|Last Vacuum|Last Auto Vacuum|Row count|Dead row count|Expect autovacuum?\n|-|-|-|-|-|-|-|\n"
×
45
        for _, r := range result {
×
46
                rowcount := strings.Replace(r.Rowcount, "-1", "No stats", 1)
×
47
                table += fmt.Sprintf("|`%s`|`%s`|%s|%s|`%s`|`%s`|`%s`|\n", r.Schema, r.Table, r.Last_vacuum, r.Last_autovacuum, rowcount, r.Dead_rowcount, r.Expect_autovacuum)
×
48
        }
×
49
        return list.RenderTable(table)
×
50
}
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