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.
Looks like a bug we need to address. Sorry about that.
Anyways, it depends on your intentions. If you just want to drop the user and retain everything it owns, then it’s typically best to re-assign ownership.
You could connect to your database as the postgres user and run something like:
REASSIGN OWNED BY <user-to-remove> TO postgres;
If you’re user owns things across multiple databases you’d need to run that query in each db.
Once your’e done with that, you should be able to drop the user.