magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

How to migrate and don't lose data? #1330

Closed SerhiiMatvieiev closed 6 years ago

SerhiiMatvieiev commented 6 years ago

Hi, I have app in production where I use MagicalRecord and setup it this way:

MagicalRecord.setupCoreDataStack(withStoreNamed: "MyAppName")

Now I want to change something in my DB, how can I do it without losing old data?

I have tried change to this:

MagicalRecord.setupAutoMigratingCoreDataStack()

but it clear all my data

willsmillie commented 5 years ago

Did you end up figuring out out to do this?

RomuloVHSYS commented 5 years ago

I'm watching this issue for a long time, probably when i tried to migrate a core data version with magicalRecord for first time.

The only solution for me, was using MagicalRecord.setupAutoMigratingCoreDataStack() and doing a Heavyweight or Lightweight Core data Migration. Creating another version for your Model(.xcdatamodeld) and doing all changes in there(the lightweight way), generally works, but depends on what you'v changed on your db scheme, you may need to create mapping models(.xcmappingmodel) and/or NSEntityMigrationPolicys.

No way to despiste that steps. You can found many tutorials of how doing migrations on te web.