Add option --drop-cascade for pg_dump/restore

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Add option --drop-cascade for pg_dump/restore

Haotian Wu


I'd like to propose adding `--drop-cascade` option for pg_dump/restore


I'd like to be able to restore an old custom format database dump as a single transaction ( so the current data won't lose if restore fails). The database has added some new constraints after backup so a CASCADE DROP is needed.

 This allows for restoring an old backup after adding new constraints,

 at the risk of losing new data.

There're already some requests for supporting cascade drop:

Design & Implementation

Basically I'm following the changes in adding `--if-exists` patch: . pg_dump/restore will inject a CASCADE clause to each DROP command.

The attached patch has been tested on our old backup. I'm happy to get some feedback.

0001-pg_dump-restore-add-drop-cascade-option.patch (22K) Download Attachment