Add a Kamal query alias for read-only database queries - #3024
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
queryalias to the SaaS Kamal config, exposing Rails 8.2's read-onlyrails queryasbin/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_connectionsalready points the reading role, whichrails queryuses by default, at thereplicaconfig and itsMYSQL_READONLY_USERcredentials.Testing
app exec -q --reuse -p -e CONSOLE_USER:<user> ... "bin/rails query".bin/kamal queryend to end —bin/kamalaborts locally in bundler before reaching the network, asGemfile.saashas uninstalled gems. Worth a run against staging before this leaves draft.Composed with Claude Code (Opus 5)