diff --git a/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m b/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m index 856f25ef26b95e003f2f6d2639fd9ac2af3cbbbe..49f69b9234b34a9eac074ddb46a26d8268d93be7 100644 --- a/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m +++ b/openbis-ipad/openBIS/openBIS/CISDOBAppDelegate.m @@ -135,6 +135,7 @@ if (_serviceManager) return _serviceManager; NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"openBISData.sqlite"]; + NSURL *openbisUrl = [self openbisUrl]; NSError *error; @@ -143,9 +144,17 @@ initWithStoreUrl: storeUrl openbisUrl: openbisUrl trusted: YES error: &error]; if (!_serviceManager) { - // TODO Implement error handling - NSLog(@"Unresolved error -- could not create service manager %@, %@", error, [error userInfo]); - abort(); + // We couldn't open the store, probably because we changed the database model. Remove the old cache and create the service manager again. + [[NSFileManager defaultManager] removeItemAtURL: storeUrl error: nil]; + + _serviceManager = + [[CISDOBIpadServiceManager alloc] + initWithStoreUrl: storeUrl openbisUrl: openbisUrl trusted: YES error: &error]; + if (_serviceManager) { + // TODO Implement error handling + NSLog(@"Unresolved error -- could not create service manager %@, %@", error, [error userInfo]); + abort(); + } } return _serviceManager;