Postgres can't detach or manually delete user and db

I’m trying to detach an app from a Postgres cluster that was added using fly pg attach.

> flyctrl pg detach -a <my-attached-app> <my-pg-app> --verbose

Yields this error:

Error error running user-delete: 500: ERROR: role "<my-attached-app>" cannot be dropped because some objects depend on it (SQLSTATE 2BP01)

Not sure how to work around as the flyctrl pg [db|users] sub commands seem limited to just list. I can see <my-attached-app>'s user and db, but can’t seem to manually delete them through flyctl.

I was able to clean up this (I think) by doing the following:

flyctl pg connect -a <my-pg-app>
# DROP DATABASE <my-attached-app-db> WITH (FORCE);
# DROP USER <my-attached-app-role> WITH (FORCE);

Would appreciate to hear if this is the correct way of doing this. Or if there are plans to add more management commands to flyctl pg.

1 Like