[Bucardo-general] Change primary key on table

Michelle Sullivan michelle at sorbs.net
Tue May 24 17:30:50 UTC 2016


emanuel at proabakus.com.br wrote:
>
> Hi everyone,
>
> I needed remove and drop table in my bucardo instance (master1, 
> master2, master3) servers, cause a table has created with a different 
> primary key columns, so I change the column name.  Example:
>
> create table a (a int primary key, b text) ;
>
> column a is wrong, instead of re-created the table with other column name
>
> drop table a ; create table a (pa int primary key, b text) ;
>
> when a executed these commands, bucardo get the first version on table 
> a with a column "a" primary key.  This make a generate 
> "delta_public_a" to be created with column "a".
>
> several commands I executed but didn't work to remove table reference 
> on bucardo environment.
>
> busardo purge, remove, etc etc.
>
> so, I made changes on bucardo delta tables (alter table 
> bucardo.delta_public_a rename column a to pa;), change trigger 
> functions ([new|old].a to [new|old].pa) and re-created index existents 
> on my three masters instances.
>
> And work!
>
> My question is if exist a way on command line or script bash or perl 
> to make this action.
>
>

If you don't have current running replication (as in changes to commit) 
you could drop (cascade) the bucardo schema and reinstall...  That would 
be the quickest and simplest - otherwise if this is a working env with 
this one problem you'll need to manually go through the bucardo tables 
and remove the errant references (psql -U bucardo bucardo to see them)

Regards,

Michelle

-- 
Michelle Sullivan
http://www.mhix.org/



More information about the Bucardo-general mailing list