MPGv2: "Delete database" returns 400, and no flyctl/API way to drop a DB

Hi team,

I’m hitting two related issues trying to delete an individual database from a Managed Postgres (MPGv2) cluster, and wanted to report them together since they compound.

Problem 1 — Dashboard “Delete database” returns 400

In the dashboard (cluster → Databases → per-row Delete), confirming the delete shows:

Failed to delete database (status 400)

This is 100% reproducible on a freshly-created database, and intermittent on older ones — clicking Delete many times in a row will eventually succeed.

What I found while debugging:

  • The backend appears to issue a plain DROP DATABASE (no WITH (FORCE)), so it fails whenever any session is connected to the target DB.
  • The only connection is Fly’s own monitoring role — _pgmonitor / application_name = pg_exporter. On a fresh database it stays connected ~22s, disconnects for ~9s, then reconnects (new PID), on roughly a 30s
    cycle.
  • So a delete only succeeds if the click happens to land in the ~9s window with no pg_exporter connection. In practice you have to spam the Delete button for ~30s.

Suggested fix: have the delete use DROP DATABASE ... WITH (FORCE), or terminate active sessions (including the monitoring connection) before dropping — so a single click works deterministically.

Problem 2 — No programmatic way to delete a database

There seems to be no supported non-dashboard path to drop a database:

  • flyctl mpg databases only has create / list — no delete.
  • DELETE /api/v1/postgresv2/{cluster}/databases/{name} returns 404 (route doesn’t exist), and there’s no GraphQL mutation for it.
  • Connecting and running DROP DATABASE doesn’t work either: all MPG databases are owned by the postgres superuser, and the default fly-user (Schema Admin) gets ERROR: must be owner of database, while
    postgres credentials aren’t retrievable.

Could you add a flyctl mpg databases delete and/or a REST endpoint? Orphaned databases (e.g. from a rolled-back automation that deleted the role but not the DB) currently have no clean self-service cleanup path
other than the dashboard button above.

Thanks!

Hi @nikolacicmil !

Thank you for bringing this to our attention and for your suggestions (:

We just shipped a fix for the dashboard and added the API endpoint for the database drop action.

curl -X DELETE https://fly.io/api/v1/postgresv2/{cluster}/databases/{name} \ 
     -H "Authorization: Bearer $FLY_API_TOKEN" 

Let us know if you need anything else

Any plan on adding it to the CLI as well?