| From: | Rounak Jain <rounakjainis(at)gmail(dot)com> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | update master db with records from slave db | 
| Date: | 2018-01-07 08:48:53 | 
| Message-ID: | CANNuxWNuG+fNrEcdNPdAF_DLBhiHC7Ar96kVdptmAFUf7SWeOA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | john snow | 2018-01-07 10:35:33 | is column order important when creating a multi-column uniqueness constraint? | 
| Previous Message | David G. Johnston | 2018-01-07 08:45:31 | Re: ?How create a one serial decimal(500,0) column or simulate it with bigint multicolumns serial? |