local Core data and evolution in a distributed system

I develop a app with core data, to create invoices for individual use. I use Int64 ID (with increment) as primary key Today, I would like to expand possibility with the same database on several iPads... BUT I can't stay with Int64 ID because first iPad create index n°1 and second iPad create invoice n°1 too !

What is the best practice to change for a distributed system : create a new id with uuid string?

thanx a lot

This is formally known as a lamport clock. Each replica (peer, I think store file in this case) needs to be issued its own identifier so that the primary key of the object is a tuple of <identifier, monotonically increasing counter>.

One such identifier is the store UUID (NSPersistentStore.identifier) which is unique to each store file. You can however use your own UUID for this purpose.

Generally, NSUUID is unique at scale, even across devices. But you may wish to use your own tuple with a deterministic / verified notion of uniqueness.

Hi docgg,

Do you care that the IDs are non-sequential or is it OK for them to be random?

It will be ok that it was non sequential...the sequential is present only for local database and not for cloud database

local Core data and evolution in a distributed system
 
 
Q