Sample Header Ad - 728x90

IF EXISTS doesn't stop errors on RDS Postgres 11.19 instance

0 votes
1 answer
316 views
Recently one of our RDS Postgres databases was upgraded to version 11.19. Since then, we're receiving errors when running a database migration. I can't replicate this issue locally, it appears to be restricted to the RDS instance only. Running this query on an empty database:
ALTER TABLE IF EXISTS ONLY public.telescope_entries_tags 
   DROP CONSTRAINT IF EXISTS telescope_entries_tags_entry_uuid_foreign;
results in the following error on RDS:
Query 1 ERROR: ERROR:  relation "public.telescope_entries_tags" does not exist
However, when running this on a local database (also Postgres 11.19) I get the following response:
NOTICE:  relation "telescope_entries_tags" does not exist, skipping

Query 1 OK: ALTER TABLE
Note, this code was auto generated inside a pg_restore command, wrapped inside a laravel function, wrapped inside some CI/CD functionality. This is the simplest case I can boil it down to. The code was generated using pg_restore (PostgreSQL) 13.11. I've checked through the differences in all the settings that are shown when running "SHOW ALL;", and copied whatever I could to the local instance, and still can't get this code to show an error locally. I just don't understand why this is classified as an error on RDS. To my mind it should be a notice. Any advice would be appreciated.
Asked by Ben Hitchcock (3 rep)
Jul 20, 2023, 10:17 AM
Last activity: Oct 2, 2023, 05:13 PM