ankane/pgsync

Sync existing rows without deleting them first

yannxaver opened this issue · 2 comments

Let's say I have one table foo + 20 other tables which are all connected to foo through foreign keys.

If there are changes to table foo I want to sync those changes.

The problem is: when I sync this table, it first deletes all existing data in table foo + all 20 related tables. Hence, I need to sync 21 tables instead of just one. How can I sync the changes in table foo without deleting the existing data in all tables first?

If I choose --preserve it doesn't delete existing rows but also doesn't update them. With --defer-constraints it still deletes all existing data.

Hi @yannxaver, pgsync doesn't support this, so you'd need to use another tool.

@ankane Do you know a tool that could accomplish this? My approach now would be to write a manual script and use the on conflict clause.