docker-pgautoupgrade icon indicating copy to clipboard operation
docker-pgautoupgrade copied to clipboard

Specify database as part of extensions upgrade

Open xanather opened this issue 2 months ago • 4 comments

Without this the line errors out if not using default database, or database name the same as user name.

xanather avatar Oct 26 '25 12:10 xanather

I am pretty sure this is wrong. if you have multiple databases with different extensions, they would not be correctly updated with your patch as it would only target one of them.

can you show the generated update_extensions.sql on your side and maybe explain more about the error? compose file is also hopeful and some information about the databases in your instance.

andyundso avatar Oct 26 '25 14:10 andyundso

The issue is that psql tries to connect to the default database and then the database with the name of the specified user. If neither exist it just errors out.

In my case, my generated update_extensions.sql only contains:

ALTER EXTENSION pgcrypto UPDATE

xanather avatar Oct 26 '25 14:10 xanather

ok, but I think then we should rather adjust our strategy to upgrade extensions by finding outdated ones in each database using SELECT * FROM pg_available_extensions WHERE default_version <> installed_version;.

andyundso avatar Oct 27 '25 20:10 andyundso

Unless i'm mistaken isn't update_extensions auto generated?

xanather avatar Oct 30 '25 12:10 xanather