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

supabase / cli / 12899221402

22 Jan 2025 01:23AM UTC coverage: 58.262% (-0.1%) from 58.378%
12899221402

push

github

web-flow
feat(postgrest-config): add delete command to cli for convenience (#3060)

0 of 26 new or added lines in 1 file covered. (0.0%)

2 existing lines in 1 file now uncovered.

7595 of 13036 relevant lines covered (58.26%)

202.64 hits per line

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

0.0
/internal/postgresConfig/delete/delete.go
1
package delete
2

3
import (
4
        "bytes"
5
        "context"
6
        "encoding/json"
7
        "strings"
8

9
        "github.com/go-errors/errors"
10
        "github.com/spf13/afero"
11
        "github.com/supabase/cli/internal/postgresConfig/get"
12
        "github.com/supabase/cli/internal/utils"
13
)
14

NEW
15
func Run(ctx context.Context, projectRef string, configKeys []string, noRestart bool, fsys afero.Fs) error {
×
NEW
16
        // 1. Get current config
×
NEW
17
        currentConfig, err := get.GetCurrentPostgresConfig(ctx, projectRef)
×
NEW
18
        if err != nil {
×
NEW
19
                return err
×
NEW
20
        }
×
21

22
        // 2. Remove specified keys
NEW
23
        for _, key := range configKeys {
×
NEW
24
                delete(currentConfig, strings.TrimSpace(key))
×
NEW
25
        }
×
26

27
        // 3. Update config with removed keys
NEW
28
        if noRestart {
×
NEW
29
                currentConfig["restart_database"] = false
×
NEW
30
        }
×
NEW
31
        bts, err := json.Marshal(currentConfig)
×
NEW
32
        if err != nil {
×
NEW
33
                return errors.Errorf("failed to serialize config overrides: %w", err)
×
NEW
34
        }
×
35

NEW
36
        resp, err := utils.GetSupabase().V1UpdatePostgresConfigWithBodyWithResponse(ctx, projectRef, "application/json", bytes.NewReader(bts))
×
NEW
37
        if err != nil {
×
NEW
38
                return errors.Errorf("failed to update config overrides: %w", err)
×
NEW
39
        }
×
NEW
40
        if resp.JSON200 == nil {
×
NEW
41
                if resp.StatusCode() == 400 {
×
NEW
42
                        return errors.Errorf("failed to update config overrides: %s (%s). This usually indicates that an unsupported or invalid config override was attempted. Please refer to https://supabase.com/docs/guides/platform/custom-postgres-config", resp.Status(), string(resp.Body))
×
NEW
43
                }
×
NEW
44
                return errors.Errorf("failed to update config overrides: %s (%s)", resp.Status(), string(resp.Body))
×
45
        }
46

NEW
47
        return get.Run(ctx, projectRef, fsys)
×
48
}
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