NSPersistentCloudKitContainer - how to reset CoreData+CloudKit after failed automatic migration (while still in development environment)

I have expanded my CoreData model quite a few times, including renaming entities, properties (and as far as I remember relationships). I am still working in the (CloudKit) development environment, only.

Now I am getting errors each time I start the app (one line out of many shown):

CoreData: debug: CoreData+CloudKit: -<PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:error:>(404): Skipping migration for 'ANSCKDATABASEMETADATA' because it already has a column named 'ZLASTFETCHDATE'

The app is working as expected, it seems this error has no effect on correct CoreData+CloudKit execution.

But I want to get rid of this error warning before I deploy to production for TestFlight or expand CoreData further. To have a clean CD+CK base I can start migrations from in future.

Can I just reset CD (or CoreData's model) to make CD accept the current model as the base model without any migrations attached to it?

An Apple Engineer suggested here to use destroyPersistentStore(at:ofType:options:), but one should be careful to call this method on NSPersistantCoodinator with the same options as when the store has been added. Since the store is created by NSPersistentCloudKitContainer I do not know the options used.

My questions are:
  1. Is the above error related to a failed automatic migration? How serious is this error/warning?

  2. Can I get rid of this error by destroying the store? Once only? Then going back to my current NSPersistentCloudKitContainer creation code.

  3. Is there any other suggested way of going forward?

  4. Would a future lightweight migrations solve this error, too?

Thank you in advance for your help!
Answered by khm2 in 672662022
Conclusions:

After
  • moving "back in time" by checking out a very early build of my app

  • with an early version of the managed object model (database description)

  • installing that app version on the simulator

  • moving forward to the latest build

the console reported a successful automatic migration of the CoreData database. After that success, the "Skipping migration" error showed up again.

I filed a feedback report to Apple and got the answer: this "skipping migration error" console output is normal/expected behaviour.

Case closed for me.
Additional info to my questions above:

even if I
  • delete the app from the test device

  • reset the Development Environment in the CloudKit dashboard for my apps container

  • then reinstall the app out of Xcode

the same "skipping migration" error shows up in the console.

This does not make sense to me. Why after all CoreData DBs on test device(s) have been cleared and newly compiled code has been installed on device. Shouldn't Xcode use the current NSManagedObjectModel as the new zero generation model, and thus not need any migration!?

What do I miss here?
Or is this a CoreData bug?


P.S. the log shows these lines:

Skipping migration for 'ANSCKMETADATAENTRY' because it already has a column named 'ZDATEVALUE'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZNEEDSUPLOAD'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZNEEDSLOCALDELETE'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZNEEDSCLOUDDELETE'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZLASTEXPORTEDTRANSACTIONNUMBER'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZPENDINGEXPORTTRANSACTIONNUMBER'
Skipping migration for 'ANSCKRECORDMETADATA' because it already has a column named 'ZPENDINGEXPORTCHANGETYPENUMBER'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZLASTFETCHDATE'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZSUPPORTSFETCHCHANGES'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZSUPPORTSATOMICCHANGES'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZSUPPORTSRECORDSHARING'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZNEEDSIMPORT'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZNEEDSRECOVERYFROMZONEDELETE'
Skipping migration for 'ANSCKRECORDZONEMETADATA' because it already has a column named 'ZNEEDSRECOVERYFROMUSERPURGE'
After upgrading to Xcode 12.5 and launching the app for the first time in the Simulator (not logged into iCloud)
  • the app loads some data into the empty CoreData database

  • no migration errors show up

After restarting the app for a second launch
  • the "skipping migration" errors are back in the log.

Accepted Answer
Conclusions:

After
  • moving "back in time" by checking out a very early build of my app

  • with an early version of the managed object model (database description)

  • installing that app version on the simulator

  • moving forward to the latest build

the console reported a successful automatic migration of the CoreData database. After that success, the "Skipping migration" error showed up again.

I filed a feedback report to Apple and got the answer: this "skipping migration error" console output is normal/expected behaviour.

Case closed for me.
NSPersistentCloudKitContainer - how to reset CoreData+CloudKit after failed automatic migration (while still in development environment)
 
 
Q