cloudfoundry / postgres-release

BOSH release for PostgreSQL
Apache License 2.0
14 stars 36 forks source link

Don't throw an error on restore, when table doesn't exist #49

Closed rkoster closed 5 years ago

rkoster commented 5 years ago

When trying to restore a database (concourse atc) we get a warning about tables which don't exist:

pg_restore: [archiver (db)] Error from TOC entry 262; 1259 19454 TABLE pipeline_build_events_1 postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  table "pipeline_build_events_1" does not exist
    Command was: DROP TABLE public.pipeline_build_events_1;

This results in a non zero exit code, which makes bbr unhappy:

[bbr] 2019/01/21 19:13:37 ERROR - Error restoring bbr-postgres-db on bosh/0.
...
[bbr] 2019/01/21 19:13:49 INFO - Cleaning up...
1 error occurred:
error 1:
Failed to restore: 1 error occurred:
error 1:
Error attempting to run restore for job bbr-postgres-db on bosh/0: pg_restore: connecting to database for restore
...
WARNING: errors ignored on restore: 3 - exit code 1

This PR addresses the above issue by using the --if-exists flag.

cfdreddbot commented 5 years ago

:white_check_mark: Hey rkoster! The commit authors and yourself have already signed the CLA.

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/163394116

The labels on this github issue will be updated when the story is started.

rkoster commented 5 years ago

@valeriap thanks for merging this PR, would it be possible to cut a final release with this fix?

valeriap commented 5 years ago

@rkoster v35 has been published.