update master db with records from slave db - Mailing list pgsql-novice

From Rounak Jain
Subject update master db with records from slave db
Date
Msg-id CANNuxWNuG+fNrEcdNPdAF_DLBhiHC7Ar96kVdptmAFUf7SWeOA@mail.gmail.com
Whole thread Raw
List pgsql-novice
Let me clarify what I mean by master and slave (since googling this issue takes me to psql master slave replication which is probably different).

I work with the slave db to create invoices with my python cli app.
I have created a master db by using

create database master with template slave owner owner_name;

For now, both db contain the same data and structure.

Now, I will delete all data from tables like sale_invoice, sale_invoice_detail etc but not from tables like customer, product etc.

I may create new entries in tables like customer, product etc or modify existing ones. I will create new invoices which shall insert new records in sale_invoice and sale_invoice_details table.

I want to be able to:

1. Add new entries created in customer, product tables to the master db
2. Modify old entries if they are modified in the slave db
3. Add new data to sale_invoice and sale_invoice_detail tables in the master db when new invoices are created in the slave db

I assume, I can do all this by matching primary keys and using insert/update but I want to know if there are better ways to do this.

Thanks.

pgsql-novice by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: ?How create a one serial decimal(500,0) column or simulate itwith bigint multicolumns serial?
Next
From: john snow
Date:
Subject: is column order important when creating a multi-column uniqueness constraint?