Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iD69U-0004aw-Mf for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2019 12:12:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iD69T-00014F-KG for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2019 12:12:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iD5lK-0003TL-7y for pgsql-general@lists.postgresql.org; Wed, 25 Sep 2019 11:47:14 +0000 Received: from mx1.riseup.net ([198.252.153.129]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iD5lG-00017m-Sl for pgsql-general@postgresql.org; Wed, 25 Sep 2019 11:47:12 +0000 Received: from capuchin.riseup.net (capuchin-pn.riseup.net [10.0.1.176]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id 9551C1A343F; Wed, 25 Sep 2019 04:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1569412028; bh=Vf+Uc/RvaFByLYab18sB4ct26PgT945m8IdQcTa0JoU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=NPdokC17vIS5sR8tGSlqXquBfYJtSnV2+Ceu8pgbyBZVeLCv9qqxqg6TlMoJhddlH e2Ns2lpVpUvpVX3U8q340/ptuuJ4eoOzjmwaUWFt9+mRCoLtLsjML6pGEICi0Xy8aU bz36Qkrchma3mokAW/+IxfpfA4YtJXCqYD8rh0Bw= X-Riseup-User-ID: 556E2DEC523FCD5F8AF025D0BA3DBCBE3DAA70AC89E92903A2AACBDEF1D04641 Received: from [127.0.0.1] (localhost [127.0.0.1]) by capuchin.riseup.net (Postfix) with ESMTPSA id EE2EF1207CB; Wed, 25 Sep 2019 04:47:06 -0700 (PDT) Subject: Re: managing primary key conflicts while restoring data to table with existing data To: Rob Sargent Cc: pgsql-general@postgresql.org References: <399629ce-aefe-d0df-7552-99fc6bc3d958@riseup.net> From: Krishnakant Mane Openpgp: preference=signencrypt Autocrypt: addr=kkmane@riseup.net; prefer-encrypt=mutual; keydata= xsFNBFofqfQBEADJJqpfeolA2X9mCKx6OfZfkaVTs1LQvb2gFctFLT9TSGN37gstOg/Ffq63 npNT2FYvxk0v23JCFu78KLmwni97OGPcTYTWYdjngAKkJ91PxbIWBtEf0b79TstoEe0OaAn4 KAt2rO+EVtMpQy95TaZcZrIFXJeuIWScHtDM64JTk/3uMgOm2sGWZQ+HSULukS6yt+k/Hd5i SAngEtFtRdxj14YqLrYgnZsGbNw4ac71KcbKsGz8HNUP0LLCf5yKOQ7MzTP0y1+M6B1GVx6z qnwO5k6dtKr0dnLsfDsdFUQMRHYKeE0JsVv/qTL18/qQtLXk/93wMMtANPG3z7Y/7AeVaxDd uSuKEZ+GARCBIzdM+Im9fHM66SePgxetwSMLuG8+rhbJhmjnBdmn5bykEjnsX40yhQi3Qi2u w3wYFYiW8AhBIm4X3W0z4VpdquYExeOnbOdTD2c5sylDfdZQl/ntRlHcf2UTFi3A/Zj8XeI2 eTihtFy0dvSgKwRQYvmwHcnKsHFGiZiGInk7Yls8tvGSO9MdNEj+2VtjE0twSeV8rog2n82k YjS1GDm5czEo1MbzxVG4khBNtidiA6IDSOX0E1gfBKc+hr/xxqY8OKsa92R91qTg8JAqQo/C sJ0IFKiXOb2xVYyDXQ39vO73ax+i/SSbwhV5nSXHNU/kPreGqQARAQABzSRLcmlzaG5ha2Fu dCBNYW5l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88RcorKhHyh7WX6Wcsd3076EF+hFxUlKZWqpA3uIk3IhzgJ8nURsRAqmH4zkVc jT7idx1lDCI= Message-ID: Date: Wed, 25 Sep 2019 17:16:56 +0530 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F1E734523BBA3D482E7E0C00" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F1E734523BBA3D482E7E0C00 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 25/09/19 4:32 PM, Rob Sargent wrote: > > > On Sep 25, 2019, at 1:15 AM, Krishnakant Mane > wrote: > >> Hello all, >> >> I have been using postgresql for an enterprise quality account's >> automation and inventory management software called GNUKhata >> >> >> Our team is planning to add backup and restore function in the software. >> >> But we don't want to dump the entire database and then restore the same. >> >> What we are trying to do is to copy data specific to an organization. >> >> The challenge here is that I might copy all data (account heads, >> bills, vouchers etc ) for one organization from an instance on one >> machine. >> >> I take the archive in what ever format to another machine and now >> attempt to restore. >> >> The risk here is for example if the primary key value for orgcode in >> the organization table is 5, it might conflict with the data where I >> am attempting it to be restored. >> >> Same holds true for bills, invoices etc. >> >> A certain account head with accountcode 1 might be already present on >> the second machine. >> >> I am not expecting the users to empty all data from the destination >> machine before restoring a backup. >> >> The reason is that an auditor may have many client's data and one >> can't predict what primary key values are going to come from a backup. >> >> Basically I can even say this is a copy paste instead of a pure >> backup and restore. >> >> Can any one suggest how to handle such conflicts? >> >> >> -- >> Regards, >> Krishnakant Mane, >> Project Founder and Leader, >> GNUKhata >> //(Opensource Accounting, Billing and Inventory Management Software)// > I’m not sure I like your definition of ‘backup and restore’ but you > might get away with your approach if your keys were UUIDs. But I’ll > bet dollars to doughnuts you’re using serial keys. Those seem to > appeal to accounting types.  -- Regards, Hi Rob, yes you are right, they are serial keys because timestamp or anything thereoff is agressively despised by the accountants and the likes. Now I am really stuck as to what could be done.Krishnakant Mane, Project Founder and Leader, GNUKhata //(Opensource Accounting, Billing and Inventory Management Software)// --------------F1E734523BBA3D482E7E0C00 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


On 25/09/19 4:32 PM, Rob Sargent wrote:


On Sep 25, 2019, at 1:15 AM, Krishnakant Mane <kkmane@riseup.net> wrote:

Hello all,

I have been using postgresql for an enterprise quality account's automation and inventory management software called GNUKhata <https://gnukhata.in>

Our team is planning to add backup and restore function in the software.

But we don't want to dump the entire database and then restore the same.

What we are trying to do is to copy data specific to an organization.

The challenge here is that I might copy all data (account heads, bills, vouchers etc ) for one organization from an instance on one machine.

I take the archive in what ever format to another machine and now attempt to restore.

The risk here is for example if the primary key value for orgcode in the organization table is 5, it might conflict with the data where I am attempting it to be restored.

Same holds true for bills, invoices etc.

A certain account head with accountcode 1 might be already present on the second machine.

I am not expecting the users to empty all data from the destination machine before restoring a backup.

The reason is that an auditor may have many client's data and one can't predict what primary key values are going to come from a backup.

Basically I can even say this is a copy paste instead of a pure backup and restore.

Can any one suggest how to handle such conflicts?


--
Regards,
Krishnakant Mane,
Project Founder and Leader,
GNUKhata
(Opensource Accounting, Billing and Inventory Management Software)
I’m not sure I like your definition of ‘backup and restore’ but you might get away with your approach if your keys were UUIDs. But I’ll bet dollars to doughnuts you’re using serial keys. Those seem to appeal to accounting types. 
--
Regards,
Hi Rob,
yes you are right, they are serial keys because timestamp or anything thereoff is agressively despised by the accountants and the likes.
Now I am really stuck as to what could be done.Krishnakant Mane,
Project Founder and Leader,
GNUKhata
(Opensource Accounting, Billing and Inventory Management Software)
--------------F1E734523BBA3D482E7E0C00--