I'm trying to upgrade my Cloud SQL instance running Postgres version 9.6 to 15 and I got the below error.
I then looked around the docs to upgrade the postgis version and found this link. It says
"Note: If you've enabled the PostGIS extension, then you can't upgrade to PostgreSQL 15. Remove the extension, perform the upgrade, and then reinstall the extension."
So, I've tried deleting the extension to see if that works, and it results with the below error
And then I found this link, and it says that I need to use self-service maintenance to roll out the latest systems manager (SSM) image. That took me to this page
Now when I use the command to grep for the availableMaintenanceVersions, nothing comes up and there is no such attribute at all in the output. And there is no single explanation anywhere as to why that attribute is missing.
Now I cannot figure out how to delete the extension to unblock me to proceed with upgrade. I logged into the instance as the owner of the database in which this extension is enabled, yet I cannot delete the extension. The user is part of the role cloudsqlsuperuser, still cannot delete the extension.
The documentation is not clear on some of the above options.
Is anyone here who can help?
Here are some steps and considerations to help you navigate through the process:
Pre-Upgrade Preparation
Managing Extensions and Permissions
Potential Ownership Change Restrictions: Cloud SQL's managed environment may prevent you from directly using the standard ALTER EXTENSION ... OWNER TO ...
command.
Drop Extensions if Necessary: For compatibility reasons or if specifically guided by the upgrade instructions, you might need to drop PostGIS extensions. Proceed with this step only if fully aware of the impact on your data and schema.
DROP EXTENSION postgis;
DROP EXTENSION postgis_tiger_geocoder;
DROP EXTENSION postgis_topology;
Upgrading PostgreSQL
Reinstalling PostGIS
Reinstall PostGIS Extensions: After the PostgreSQL upgrade, reinstall compatible versions of the PostGIS extensions to restore all spatial features.
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION postgis_topology;
Post-Upgrade Actions
Support and Documentation
Important Notes
Thank you for the response.
I've tried the DROP command already and it complains about the ownership error.
I've in fact tried to follow the instructions from one of your responses here https://www.googlecloudcommunity.com/gc/Databases/Unable-to-DROP-EXTENSION-in-Cloud-SQL-for-Postgres...
And the below command returns nothing
SELECT extname FROM pg_extension WHERE extowner NOT IN (SELECT oid FROM pg_roles);
Your observation that the query SELECT extname FROM pg_extension WHERE extowner NOT IN (SELECT oid FROM pg_roles);
returns no results is insightful. It indicates that all PostGIS extensions currently have valid owners, which are recognized within the PostgreSQL system. This result suggests the challenge isn't due to orphaned extensions but rather stems from the restricted permissions typical in a managed environment like Cloud SQL.
In this scenario, the most straightforward and advisable course of action is to reach out to Google Cloud Support.
To expedite the support process, it's beneficial to prepare the following information:
that absolutely makes no sense to me and it flags a security issue. How can GCP support access a database that is owned by customer? That's not even a systems database, and I'm concerned about the security of the database.
Google Cloud Support may temporarily need to access customer-owned databases within Cloud SQL for tasks like extension management, complex troubleshooting, or applying critical updates. Google Cloud maintains stringent security protocols, including role-based access control (RBAC), comprehensive auditing, robust data encryption, and compliance with leading industry standards, to ensure the highest levels of data security and privacy. If you have concerns about Cloud Support accessing your database:
It's important to recognize that managed database services like Cloud SQL can offer enhanced security capabilities, thanks to the provider's dedicated resources, specialized expertise, and continuous investment in security infrastructure. These services are designed to maintain, if not improve, your data's security posture.