Re: #fabric #database #couchdb #fabric-chaincode #hyperledger-fabric #fabric #database #couchdb #fabric-chaincode #hyperledger-fabric


David Enyeart
 

The second version of the chaincode would have to support both the old and new data. There are various approaches possible:

You could attempt to unmarshal the JSON using new data structure, and if it doesn't work unmarshal it using the old data structure.

You could update each key/value to the new data structure each time the key is updated in chaincode.

You could iterate through each key (in batches driven by range queries) after the second version is deployed and update each key/value to the new data structure in a series of transactions. Then deploy a third version that only supports the new data structure.

Better yet, you could attempt to design the JSON with extension in mind so that you can add fields, such that the old and new data can both unmarshal to an updated data structure.

Let's collect some other thoughts here, and then the documentation can be updated to reflect the various ideas.


Dave Enyeart

keerthycbe---07/30/2020 01:02:45 PM---I've a query on how we need to deal with data structure changes in chaincode. Lets say, you have dep

From: keerthycbe@...
To: fabric@...
Date: 07/30/2020 01:02 PM
Subject: [EXTERNAL] [Hyperledger Fabric] #fabric #database #couchdb #fabric-chaincode #hyperledger-fabric
Sent by: fabric@...





I've a query on how we need to deal with data structure changes in chaincode. Lets say, you have deployed the chaincode in production and lot of data stored in ledger and world state db(Couchdb). If you have changed the data structure drastically in chaincode (Added/removed/changed some fields) for your next release, I would like to understand how to manage the old data in Couchdb. The new data with new data structure will be stored along with old data. While querying the data, client would be getting data with old and new structure. I've following questions with respect to this.
I'm not sure if there is a way to migrate old data as per new structure in Couchdb and Ledger. I understand we can't change data in World State DB alone as the data is computed based on the transactions in the ledger which is immutable. can you please guide what strategy should we follow to handle the data model significant changes in chaincode in production?



Join fabric@lists.hyperledger.org to automatically receive all group messages.