[Bucardo-general] how to RENAME tables in postgres, replicated by bucardo

Greg Sabino Mullane greg at endpoint.com
Fri Apr 21 03:26:14 UTC 2017


On Tue, Apr 18, 2017, Nina Markova wrote:

> I need to RENAME couple of tables in postgres, which are 
> replicated via BUCARDO on MASTER-MASTER setup.

That's a little tricky, as the table names are hard-coded in an few places. The 
easiest way is probably this:

1) Make sure nothing is modifying the table, so that we don't discard any deltas
2) Do a final kick of the sync, to clear out any deltas
3) Stop Bucardo
4) Rename the table via ALTER TABLE
5) Drop the 'bucardo_delta' trigger on the table: DROP TRIGGER bucardo_delta on xyz;
   (the other two triggers you may see are tablename-agnostic)
6) Drop and re-add the table via the 'bucardo' program:
   bucardo remove table public.abc
   bucardo add table public.xyz relgroup=foobar
7) Run validate sync to add the new bucardo_delta trigger:
   bucardo validate all
8) Start up Bucardo

If it's a real busy database and you cannot ensure the deltas will not build up, 
one could do it a more careful, but much more involved way, by renaming the 
trigger, adding the new one, copying delta rows from old delta table to the 
new one, then removing the old bucardo_delta trigger.

-- 
Greg Sabino Mullane greg at endpoint.com
End Point Corporation
PGP Key: 2529 DF6A B8F7 9407 E944  45B4 BC9B 9067 1496 4AC8
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://mail.endcrypt.com/pipermail/bucardo-general/attachments/20170420/0413afdf/attachment.sig>


More information about the Bucardo-general mailing list