ankane/pgsync

[Feature] schema-only should confirm before existing table is dropped!

sunapi386 opened this issue · 1 comments

The flag --schema-only is misleading, if it drops the table there needs to be user confirmation!

Although the documentation states so, it would be easy to miss. Please enforce and add confirmation (y/n) in code before proceeding. Optionally, add a flag --drop-if-conflict and drop table if the schema sync fails.

Currently the docs say

Sync schema before the data (this wipes out existing data)

pgsync --schema-first
Specify tables

pgsync table1,table2 --schema-first
Or just the schema

pgsync --schema-only

Hey @sunapi386, thanks for the suggestion. Most pgsync operations delete/truncate existing data, so I'm not sure this is much different from other operations in terms of safety (although there's probably a better name for it).

pgsync checks the destination database is local (or --to-safe is passed) as the primary safety check.

I've adjusted the docs to try to make it clear --schema-only wipes data as well, and will leave this open to think about other changes for when there are existing tables.