Skip to content

Commit 3c5c827

Browse files
committed
feat: support postgres config update without restart
1 parent 4d8e3e6 commit 3c5c827

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

cmd/postgres.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ var (
2929
Long: `Overriding the default Postgres config could result in unstable database behavior.
3030
Custom configuration also overrides the optimizations generated based on the compute add-ons in use.`,
3131
RunE: func(cmd *cobra.Command, args []string) error {
32-
return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, afero.NewOsFs())
32+
return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, noRestart, afero.NewOsFs())
3333
},
3434
}
3535

3636
postgresConfigValues []string
3737
postgresConfigUpdateReplaceMode bool
38+
noRestart bool
3839
)
3940

4041
func init() {
4142
postgresCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
4243
postgresCmd.AddCommand(postgresConfigGetCmd)
4344
postgresCmd.AddCommand(postgresConfigUpdateCmd)
4445

45-
postgresConfigUpdateCmd.Flags().StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair")
46-
postgresConfigUpdateCmd.Flags().BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.")
46+
updateFlags := postgresConfigUpdateCmd.Flags()
47+
updateFlags.StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair")
48+
updateFlags.BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.")
49+
updateFlags.BoolVar(&noRestart, "no-restart", false, "Do not restart the database after updating config.")
4750

4851
rootCmd.AddCommand(postgresCmd)
4952
}

internal/postgresConfig/update/update.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/supabase/cli/internal/utils"
1414
)
1515

16-
func Run(ctx context.Context, projectRef string, values []string, replaceOverrides bool, fsys afero.Fs) error {
16+
func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error {
1717
// 1. Prepare config overrides
1818
newConfigOverrides := make(map[string]string)
1919
for _, config := range values {
@@ -49,6 +49,9 @@ func Run(ctx context.Context, projectRef string, values []string, replaceOverrid
4949
}
5050
// 4. update config overrides and print out final result
5151
{
52+
if noRestart {
53+
finalOverrides["restart_database"] = false
54+
}
5255
bts, err := json.Marshal(finalOverrides)
5356
if err != nil {
5457
return errors.Errorf("failed to serialize config overrides: %w", err)

0 commit comments

Comments
 (0)