mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
model versions rollback,then how to migrate ??? #370
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CoderCMY on GitHub (Jul 20, 2021).
For example,In TestFlight We publish a new app version and we update the "xcdatamodeld" model version that is “v10”, In AppStore the "xcdatamodeld" model version that is “v9”,when a user installed the testflight version first, then he installed the AppStore version again for some reason, as a result stored data in database is gone。So is there anyway to ensure CoreStore migrate succeed in this situation
@JohnEstropia commented on GitHub (Jul 20, 2021):
If you want to support this then you have to write a migration for
V10→V9. That's the only way@CoderCMY commented on GitHub (Jul 20, 2021):
Under normal conditions,our CoreStore Initialization method is below,according to you advice,what's the right code
@JohnEstropia commented on GitHub (Jul 21, 2021):
You use
recreateStoreOnModelMismatch, which means the database will be reset on a "downgrade".If you want to keep data intact even if your testers downgrade your app version, you need to create an xcmappingmodel from v10 to v9, similar to how you'd prepare a migration from v9 to v10
@CoderCMY commented on GitHub (Jul 21, 2021):
Sorry,I guess you don’t understand my question completely,your solution is create an xcmappingmodel from v10 to v9,In this way it is necessary I have to upload a new version to AppStore???my situation is like this,For example,we have published a version 5.0 the "xcdatamodeld" model version that is “v9” In AppStore ,A few days later,We publish a new version 5.1 and we update the "xcdatamodeld" model version that is “v10” In TestFlight 。when a tester installed the testflight version 5.1 and used some days, then he installed the AppStore version 5.0 again for some reason。 as a result stored data in database is gone,so my question is how to solve this problem .
@JohnEstropia commented on GitHub (Sep 23, 2021):
It's been a while and I hope you had resolved this issue...
Yes I did understand the situation, but my answer stands that the only way you can "downgrade" models is if you provide a mapping model from the newer version into the older version. This means you have to "mock" your older app version with a newer version that uses the old DB model but with newer mapping models.