core-data-migration

Skipping painful migration with Core Data and move to the new data model

折月煮酒 提交于 2019-12-03 20:49:40
I'm spending a lot of time massaging core data into a new migration when I don't even care about the old data. Instead of dealing with the hassle of mapping models each time I change my data model, is there a way to just delete all existing data and jump to the new data model? Yep, just delete the store file and recreate it. I often (at least in development) have my code try an auto migration, and if that fails, blow away the store and start over: // storefile is an NSURL to the store file, mom is the NSManagedObjectModel NSError *err = nil; NSPersistentStoreCoordinator *psc = [[

Core data migration - how to combine two entities into one

强颜欢笑 提交于 2019-12-03 20:46:44
I have a old core data model with two entities: First entity FirstString has an attribute: string1 which is NSString Second entity SecondString has an attribute: string2 which is NSString They have a one to many relationship: first entity <--->> second entity. The new entity - "ComboEntity" - has one to one relationship with both first entity and second entity. Now I have new core data model with new entity ComboEntity has an attribute: fullString Question: How do I migrate the data and combine string 1 and string 2 into fullString? Thanks! svena You should use a custom mapping policy. Create

How to migrate core data by deleting old one on App Update

风流意气都作罢 提交于 2019-12-03 20:22:30
Hi I'm going to update my iOS app in appstore and this update contains database change so now how to migrate my existing core data by deleting old database of existing version on App update? I have referred Core Data Migration tutorial Core Data Migration Post Unfortunately of no use. Any help is appreciated in advance Smith, I presume you have done some schema changes, in the xcdatamodel Always, Add a new Model Version (Select name.xcdatamodeld then Editor->Add model Version) before making any changes, if you have an app already submitted to App Store which is using the earlier model version.

Core data migration failing with “Can't find model for source store” but managedObjectModel for source is present

戏子无情 提交于 2019-12-03 16:48:03
问题 I have a cocoa application using core-data, which is now at the 4th version of its managed object model. My managed object model contains abstract entities but so far I have managed to get migration working by creating appropriate mapping models and creating my persistent store using addPersistentStoreWithType:configuration:options:error and with the NSMigratePersistentStoresAutomaticallyOption set to YES. NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber

How do I set default values on new properties for existing entities after light weight core data migration?

南楼画角 提交于 2019-12-03 14:38:59
问题 I've successfully completed light weight migration on my core data model. My custom entity Vehicle received a new property 'tirePressure' which is an optional property of type double with the default value 0.00. When 'old' Vehicles are fetched from the store (Vehicles that were created before the migration took place) the value for their 'tirePressure' property is nil. (Is that expected behavior?) So I thought: "No problem, I'll just do this in the Vehicle class:" - (void)awakeFromFetch {

How to Do a Lightweight CoreData Migration in Swift

天大地大妈咪最大 提交于 2019-12-03 13:27:48
问题 I am attempting my first lightweight CoreData migration. I read two guides on lightweight migrations. Both add code to a CoreDataStack class, modifying variables like NSPersistentStoreCoordinator and adding: let mOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true] My problem is that I have a perfectly functioning app using CoreData but I don't have that class or anything like it. My problem is , why do these projects assume I have this

Changing Attribute Type in Core Data with NSInferMappingModelAutomaticallyOption

∥☆過路亽.° 提交于 2019-12-03 11:50:28
I have my Core Data Store and I use the flag 'NSInferMappingModelAutomaticallyOption' so that whenever I make changes to the Core Data Model I first create a new model version, and the changes to the data models are automatically migrated. However, I need to change an attribute type for one of my Entities. When I do this, the automatic migration doesn't seem to work and I get a Core Data error when I try to run my app. Any way of setting this up to continue with the automatic model migration? Attribute type change is not supported by the lightweight migration: For Core Data to be able to

Core Data: how to just delete and rebuild the data store?

跟風遠走 提交于 2019-12-03 09:57:31
问题 I'm using Core Data in an iOS 7+ app that does not need to save user's data, all data the app needs is requested to services and it can be recovered at any time. So, if I change my data model in a next app update, I have no problem in deleting all the previous data and requesting it all again. But I don't know how to simply replace the previous data model with the new one, without performing a migration since it looks that I don't need to do that... Thanks in advance 回答1: Case 1: You're using

Core data migration failing with “Can't find model for source store” but managedObjectModel for source is present

怎甘沉沦 提交于 2019-12-03 06:38:36
I have a cocoa application using core-data, which is now at the 4th version of its managed object model. My managed object model contains abstract entities but so far I have managed to get migration working by creating appropriate mapping models and creating my persistent store using addPersistentStoreWithType:configuration:options:error and with the NSMigratePersistentStoresAutomaticallyOption set to YES. NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]; NSURL *url = [NSURL fileURLWithPath:

Core Data: how to just delete and rebuild the data store?

徘徊边缘 提交于 2019-12-03 00:27:42
I'm using Core Data in an iOS 7+ app that does not need to save user's data, all data the app needs is requested to services and it can be recovered at any time. So, if I change my data model in a next app update, I have no problem in deleting all the previous data and requesting it all again. But I don't know how to simply replace the previous data model with the new one, without performing a migration since it looks that I don't need to do that... Thanks in advance Case 1: You're using a SQLite store This applies if your store type is NSSQLiteStoreType . Even if you plan to delete your data