Detach postgres from non-interactive terminal

We are building automation to restore DB dumps of our application in different environments. The automation runs within Github Actions.

When we try to run flyctl postgres detach to detach the previous database it fails with “Error: prompt: non interactive”. It seems there is no option to bypass manual selection of the attachment.

How can we achieve what we need? I’ve tried using commands like yes to try to bypass the confirmation but that did not work.

Hi… It looks like this is a known limitation, :snowflake::

// TODO - This process needs to be re-written to suppport non-interactive terminals.
func detachAppFromPostgres(ctx context.Context, leaderIP string, app *fly.AppCompact, pgApp *fly.AppCompact) error {

On the bright side, this command doesn’t appear to be doing anything dauntingly complicated… For example, the secret you can delete yourself through other means, and the user can be removed via SQL. At a glance, the remaining piece is an API call to de-register the attachment in the Fly.io platform’s metadata (?). Perhaps you could just snoop on the HTTP traffic and see what that last one looks like.

Hope this helps a little!

Added flyctl, postgres, wishlist

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.