Core Data Migration Tips / Feedback

Wondering what people have changed from the books implementation of custom migrations? One thing I ran into is that when running migrateStoreAt, temporary files are never cleaned up.

Should run

        do {
            try fileManager.removeItem(at: destination)
        } catch {
            log.error(error)
        }

Before running migrationManager.migrateStore.

Hey @maximilian!

I don’t think that the -wal and -shm counterpart files are to do with migration. They’re related to the default journalling mode used by SQLite and I don’t think that they should be deleted during migrations.

This post should better explain what they are doing: http://pinkstone.co.uk/how-to-remove-wal-files-in-core-data/

Hope that helps :+1:

1 Like

Hi @liamnichols! Thanks for the tip. My bad :sweat_smile:

1 Like

@liamnichols Running migrations again and I realize why I clean those files up, the migration creates a ~1 version of the files to move it, should the -wal and -shm files be cleaned up? or moved to replace the original ones?