objective c - Core Data: Database migration causes duplicates -
few customers reported after core info migration, database entries result duplicated.
we opened databases sent , indeed entries duplicated. restore backup , convert 1 time again database, can't reproduce issue in office. migration works.
what reason of duplication? related construction of model, or else?
it's lightweight migration using model mappings. core info databases based on mysql.
thanks
after battling while, solution pretty obvious us. happen very hard find repro (and harder find reason!).
it seemed app crash mid-migration (for unknown reasons).
we using deterministic file names destinationurl
in -[nsmigrationmanager migratestorefromurl:...]
appdata.sqlite-model_version_2.3
. weren't checking existence of destination before migrating, , nsmigrationmanager
re-create straight regardless..so we'd duplicates of every entity first (crashed) attempt, , singles of after that.
a few -[nsfilemanager removeitematpath:error:]
calls .sqlite
, .sqlite-shm
, .sqlite-wal
before attempting migration clean previous failed migration have solved problem us.
objective-c osx cocoa core-data
No comments:
Post a Comment