MCPcopy Index your code
hub / github.com/coder/coder / builtinPostgresURL

Function builtinPostgresURL

scripts/develop/dbrecovery.go:489–507  ·  view source on GitHub ↗
(cfg *devConfig)

Source from the content-addressed store, hash-verified

487}
488
489func builtinPostgresURL(cfg *devConfig) (string, error) {
490 pgDir := filepath.Join(cfg.configDir, "postgres")
491
492 portBytes, err := os.ReadFile(filepath.Join(pgDir, "port"))
493 if err != nil {
494 return "", xerrors.Errorf("read postgres port: %w", err)
495 }
496 port := strings.TrimSpace(string(portBytes))
497
498 passwordBytes, err := os.ReadFile(filepath.Join(pgDir, "password"))
499 if err != nil {
500 return "", xerrors.Errorf("read postgres password: %w", err)
501 }
502 password := strings.TrimSpace(string(passwordBytes))
503
504 return fmt.Sprintf(
505 "postgres://coder@localhost:%s/coder?sslmode=disable&password=%s",
506 port, url.QueryEscape(password)), nil
507}
508
509func resetSchema(ctx context.Context, db *sql.DB) error {
510 tx, err := db.BeginTx(ctx, nil)

Callers 1

updateMigrationTrackingFunction · 0.85

Calls 2

ReadFileMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected