Search code examples
phpsqldatabasepostgresqlreplication

How to to capture & apply changes from specific tables on a postgresql database to a master postgresql database


I need to capture & apply changes from specific tables on a postgresql database to a master postgresql database, I only need the insert/update/delete events over those specific tables, I found an example using Audit_trigger_91plus! for capture the changes over my tables, but i don't know if this is a good idea, cause after the capture I need to convert this logs into sql statements, escape the values, and check the concurrency. My question is if there are another simplest way to achieve that. PHP it's used for the application over those two databases and for the future replication services and management.


Solution

  • Finally I solved my problem, The solution was to implement a java app who read the changes stored in the audit table (thanks to the Audit_trigger_91plus), transform this hstore data into valids sql statements using sql injection, and then apply one by one in master database. Thank you all and if you find another better approach please add your comments.