Skip to content

Add a Kamal query alias for read-only database queries - #3024

Merged
lewispb merged 1 commit into
mainfrom
add-kamal-query-alias
Aug 5, 2026
Merged

Add a Kamal query alias for read-only database queries#3024
lewispb merged 1 commit into
mainfrom
add-kamal-query-alias

Conversation

@lewispb

@lewispb lewispb commented Aug 5, 2026

Copy link
Copy Markdown
Member

What

  • Adds a query alias to the SaaS Kamal config, exposing Rails 8.2's read-only rails query as bin/kamal query.

Why

BC5 and HEY already carry this alias, so tooling that asks production data questions has one command shape across apps — Fizzy was the gap. Nothing else was needed: configure_replica_connections already points the reading role, which rails query uses by default, at the replica config and its MYSQL_READONLY_USER credentials.

Testing

  • Rendered the ERB and parsed the YAML: the alias expands to app exec -q --reuse -p -e CONSOLE_USER:<user> ... "bin/rails query".
  • Did not run bin/kamal query end to end — bin/kamal aborts locally in bundler before reaching the network, as Gemfile.saas has uninstalled gems. Worth a run against staging before this leaves draft.

Composed with Claude Code (Opus 5)

Rails 8.2 ships `rails query`, a read-only query interface that connects to
the reading replica role by default. Fizzy already has the wiring it needs:
ApplicationRecord's configure_replica_connections points the reading role at
the `replica` config, which uses MYSQL_READONLY_USER credentials.

This exposes it as `bin/kamal query`, matching the alias bc3 and haystack
already carry so tooling can use one command across apps.

Shaped after the neighbouring console alias rather than bc3's, since Fizzy
defines no `console` role — just `web` and `jobs`. `-p` keeps a
non-interactive exec from fanning out across all eight web hosts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lewispb
lewispb marked this pull request as ready for review August 5, 2026 22:12
Copilot AI balanced review requested due to automatic review settings August 5, 2026 22:12
@lewispb
lewispb merged commit 72f7c0d into main Aug 5, 2026
13 checks passed
@lewispb
lewispb deleted the add-kamal-query-alias branch August 5, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a SaaS Kamal alias for running Rails 8.2 read-only queries against the configured replica.

Changes:

  • Adds bin/kamal query.
  • Forwards operator metadata for auditing.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants