flyctl mpg attach tracks app attachments to MPG clusters
Introduced 2026-01-08 · score 0.95
HOW TO USE IT
When connecting an app to a Managed Postgres cluster, run `fly mpg attach` to add a connection secret and create the attachment record. Use `fly mpg attach list` to verify attached app names; use `fly mpg detach` to remove the attachment while retaining the secret.
fly mpg attach <CLUSTER_ID> --app <APP_NAME>fly mpg detach <CLUSTER_ID> --app <APP_NAME>WHY THIS HELPS
When connecting an app to a managed Postgres cluster, attach the cluster to the app and verify its attachments.
BEFORE THIS CHANGE
Previously `mpg attach` created a secret and deployed; it did not create an explicit database connection record between the cluster and app.
REQUIREMENTS AND LIMITATIONS
- Version: v0.4.2
- <CLUSTER_ID>: Managed Postgres cluster ID; when omitted, the command prompts for a cluster.
- --app <APP_NAME> (required): Select the app to attach or detach; the command requires an app name.
- --variable-name <NAME>: Secret environment variable name to add to the app; defaults to `DATABASE_URL`.
- --database, -d <NAME>: Database to connect to; when omitted, an interactive session prompts for selection.
- --username, -u <NAME>: Database user to connect as; when omitted, an interactive session prompts for selection.
- Prerequisite: A Fly.io authenticated session is required.
- Prerequisite: The app and cluster must belong to the same organization.
- `mpg detach` removes the attachment but does not remove the secret.
FIRST-PARTY EVIDENCE
- https://github.com/superfly/flyctl/releases/tag/v0.4.2
- https://github.com/superfly/flyctl/pull/4717
- https://github.com/superfly/flyctl/blob/v0.4.2/internal/command/mpg/attach.go
- https://github.com/superfly/flyctl/blob/v0.4.2/internal/command/mpg/detach.go
Check the installed version and the source before using it. Entry JSON