(cfg *devConfig)
| 487 | } |
| 488 | |
| 489 | func 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 | |
| 509 | func resetSchema(ctx context.Context, db *sql.DB) error { |
| 510 | tx, err := db.BeginTx(ctx, nil) |
no test coverage detected