-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Sync after migrating Persistent Stores #59
Comments
@paulw11 I am having the same issue. Can you please take a look into this? |
There could be other issues, but one thing that jumped at me looking at your code, is that you are enabling
Important note: I am not using the published version of Seam3 - I have a pending Pull Request #57 (PR is waiting for @paulw11 to merge)that does a few things to facilitate the migration, in particular:
|
Thank you @tifroz for taking the time to answer.
Store options are:
Thank you once again. |
@unniverzal Hey. Yes, I did. My code:
|
I have now merged @tifroz PR into the master branch. I will update the POD shortly |
@unniverzal |
@DJ-Glock Hey I went through your code when are you calling |
@unniverzal Hey. Nowhere. I have decided to not use auto sync and it is run manually by pressing the button. Not an ideal solution because of issue #61 :( |
@unniverzal Hey!
|
@DJ-Glock Hey I am trying to figure this out myself. What exactly are you doing here? if seamStoreExists {
// If exists, then use it because it has been already migrated to Seam3 storage
print("Already migrated, using \(newURL)")
var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
let coordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel)
do
{
let options: [String : Any] = [NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true,
SMStore.SMStoreContainerOption: "iCloud.iGlock.CafeManager.com",
SMStore.SMStoreSyncConflictResolutionPolicyOption: NSNumber(value:SMSyncConflictResolutionPolicy.clientTellsWhichWins.rawValue)]
try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: newURL, options: options)
} catch {
NSLog("Error initializing smStore for iOS 8+ - \(error.localizedDescription)")
}
return coordinator
}()
var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = persistentStoreCoordinator
return managedObjectContext
} else {
// If does not exist, then migrate old storage to Seam3.
print("Not yet migrated, migrating to \(newURL)")
var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
let coordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel)
// Initializing old store
do {
let options: [String : Any] = [NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true]
let oldStore = try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: oldURL, options: options)
// Migrate old store to Seam3
do
{
let options: [String : Any] = [NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true,
SMStore.SMStoreContainerOption: "iCloud.iGlock.CafeManager.com",
SMStore.SMStoreSyncConflictResolutionPolicyOption: NSNumber(value:SMSyncConflictResolutionPolicy.clientTellsWhichWins.rawValue)]
try coordinator.migratePersistentStore(oldStore, to: newURL, options: options, withType: SMStore.type)
} catch {
NSLog("Error initializing smStore for iOS 9 - \(error.localizedDescription)")
}
} catch {
NSLog("Error initializing default NSSQLiteStore for iOS 9 - \(error.localizedDescription)")
}
return coordinator
}()
var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = persistentStoreCoordinator
return managedObjectContext
} Sepcifically, why are you creating a coordinator if the Seam store exists? |
Hello Paul.
When trying to migrate data from a
NSSQLiteStoreType
toSMStore
type persistent store, the data is migrated to the new store but not loaded to Cloud. If data is added ,after migration in SMStore persistence store, or the previous data is edited then they are loaded to Cloud.What I am doing is:
And the options are:
The text was updated successfully, but these errors were encountered: