This document describes how to add a table to an existing Bruce replication cluster1. An familiarity with administering PostgreSQL is presumed of the reader.

The simple case: A brand new table

pg_dump -n <table schema name> -t <table name> <master database> | psql -a <slave database>
psql <slave database> 
create trigger <table name>_deny 
BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> 
FOR EACH ROW EXECUTE PROCEDURE bruce.denyaccesstrigger();
\q
psql <master database>
create trigger <table name>_sn 
BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> 
FOR EACH STATEMENT EXECUTE PROCEDURE bruce.logsnapshottrigger();
create trigger <table name>_tx 
AFTER INSERT OR DELETE OR UPDATE ON <fully qualified tables name> 
FOR EACH ROW EXECUTE PROCEDURE bruce.logtransactiontrigger();
\q 

The not so simple case: An already populated table

psql <master database>
begin work;
lock table bruce.currentlog in access exclusive mode;
--- Keep this transaction open for now
pg_dump -h <master host> -n <table schema name> -t <table name> <master database name> | 
psql -h <slave hostname> <slave database name>
psql <slave database> 
create trigger <table name>_deny 
BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> 
FOR EACH ROW EXECUTE PROCEDURE bruce.denyaccesstrigger();
\q
create trigger <table name>_sn 
BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> 
FOR EACH STATEMENT EXECUTE PROCEDURE bruce.logsnapshottrigger();
create trigger <table name>_tx 
AFTER INSERT OR DELETE OR UPDATE ON <fully qualified tables name> 
FOR EACH ROW EXECUTE PROCEDURE bruce.logtransactiontrigger();
commit;
\q
Footnotes

1. For now. In a future version of Bruce, a method will be provided to ease this process.
2. Replace text within <> with appropriate values.