Hi @ Alex
I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.
Issue:
Recently our demo database was automatically upgraded to Postgres 16.8.
This immediately caused an issue where dropping, creating and migrating the database causes a new error.
PG::FeatureNotSupported: ERROR: extension "plpgsql" is not allow-listed for "azure_pg_admin" users in Azure Database for PostgreSQL (PG::FeatureNotSupported)
If you follow the options for support, you find a section explaining the following:
plpgsql We have currently disabled the available to control on plpgsql extensions (removed from azure.extensions), because it is enabled by default and utilized internally for other operations and extensions, so removing this extension will also remove any dependencies it has on other operations and extensions. Make sure you are removing this extension from your template if you are explicitlys using to prevent any conflict in your deployment.
This explains that you don't need to enable the extension because it's already enabled. However, the above error clearly shows it is not enabled (or if it is, it is not accessible by the user).
How do we resolve this?
Solution:
By adding this line to our migration code, we avoid the issue on environments that need to migrate the database from the start.
class EnableExtensions < ActiveRecord::Migration[6.0]
def change
enable_extension 'uuid-ossp'
enable_extension 'pgcrypto'
enable_extension 'plpgsql' unless extension_enabled?('plpgsql') # modified line
end
end
It did take a lot of work to get there, but this seems to be the smallest amount needed.
Interestingly loading the schema doesn't have the same error, even though it also enabled the extension. Perhaps Postgres knows it's already enabled so doesn't bother.
If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.
Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.