Merging two store files into one

Hi, i'm working on an App where the original developer inadvertently created a Core Data stack with two store files. Instead of setting persistentStoreDescriptions to a single PersistentStoreDescription, one was appended to persistentStoreDescriptions:


let persistentContainer = NSPersistentContainer(name: "AppModel")

let storeURL: URL // URL pointing to a file under "Documents" folder
let persistentStoreDescription = NSPersistentStoreDescription(url: storeURL)

persistentContainer.persistentStoreDescriptions.append(persistentStoreDescription)


The above ends up creating two store files, one under "Library/Application Support" and a second one under the "Documents" folder.


Is there a way i can combine the two store files into one?

Which location do you intend to carry forward, assuming the two stores are unique, of course...

Merging two store files into one
 
 
Q