Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magical record migration failing "Can't find model for source store"

We made some changes to our CoreData model and looks like the auto migration is failing.

Even when we set the current model to be the original model that we used to generate the data there's still the error:

reason = "Can't find model for source store";

2014-09-05 02:19:43.297[948:166846] -[LBAppDelegate application:willFinishLaunchingWithOptions:] line 132 $ WILL FINISH!!
2014-09-05 02:19:43.402[948:166846] +[LBParse ensureUserObjectExists] line 107 $ dont save
2014-09-05 02:19:52.395[948:166846] CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///var/mobile/Containers/Data/Application/0B3D4097-940C-433F-B6E5-E0EA6B08992F/Library/Applicat... options:{
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    NSSQLitePragmasOption =    {
        "journal_mode" = WAL;
    };
} ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x180f8620 {URL=file:///var/mobile/Containers/Data/Application/0B3D4097-940C-433F-B6E5-E0EA6B08992F/Library/Applicat..., metadata={
    NSPersistenceFrameworkVersion = 519;
    NSStoreModelVersionHashes =    {
        AccessItem = <c81a9dbd 17033d2e 91d33b1c fc94ab08 bd3619e2 b5fea24d 6881959a f8023dc5>;
        AccessRule = <e0fd9950 87366a29 fa6702bf 7e7acc3a 86c2f088 3875c341 81414177 4720eee8>;
        Airline = <f8491ecb 2628a003 143b935b 3d3c291b fac507d8 2339af1b 1ac0fe8b 04b73602>;
        Airport = <09e93c0e fbf1e542 d1428584 30549a84 2e0cb9d3 8b50a508 31807dec d7e5f845>;
        Alliance = <b9b53f23 d5962f3f b7a0a3a5 5ca84d83 61d81f7c 0787ca6a dfdfdf21 733b5e4d>;
        AllianceTier = <6ec8bee0 5d4c62f8 1411eaab b464d783 c6388b12 06506824 f11d6453 a58e509a>;
        Amenity = <86065297 64aff55b b7bfec32 e8e14b74 5d7afa5b 751e760e e37e6294 2e40e26a>;
        Data = <92870bec c4a8794e 293dcbe9 93282d69 cb675039 cb9b9bf6 8dda6359 34697663>;
        Event = <de060947 8ec9f2bb 80e341eb 787e7eec 7cc2a09f 356e511c 7d515ca5 130690fe>;
        FeedItem = <1d0d12fc 82eb532a c1a42ad3 57022129 2c44360e ab5514ce a44d6de0 719ca798>;
        Image = <94e1ad81 4a2aa37b 6a02a52e fb481891 5028fafc 0645de55 7316e5d9 f630ca85>;
        Lounge = <57e5d036 c67f1f9d b3c731a6 4136866e 008684b0 f2ec0620 58e6e56c dbbed4fe>;
        ParseObject = <bfa49e8c 1108961a 49848584 0f2fe83f 082bdc6a 2948e09f 68a84c50 2acb0699>;
        Review = <b423b85c 47d15ee8 bbacbfcf 019fb741 165da2ab 5fa6f087 1975bb31 712bdb64>;
        User = <8451767f db80e10a 15ea83d8 83dc1a2c e89d1699 0b302640 59a23144 61c65be0>;
        Vote = <38d267c9 0c44854e dd01201c b728b906 21fd25cd 8343a416 adf769c6 faef7cb6>;
    };
    NSStoreModelVersionHashesVersion = 3;
    NSStoreModelVersionIdentifiers =    (
        ""
    );
    NSStoreType = SQLite;
    NSStoreUUID = "222748EF-2F19-4B87-829C-F8171E439430";
    "_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store} with userInfo dictionary {
    URL = "file:///var/mobile/Containers/Data/Application/0B3D4097-940C-433F-B6E5-E0EA6B08992F/Library/Applicat...";
    metadata =    {
        NSPersistenceFrameworkVersion = 519;
        NSStoreModelVersionHashes =        {
            AccessItem = <c81a9dbd 17033d2e 91d33b1c fc94ab08 bd3619e2 b5fea24d 6881959a f8023dc5>;
            AccessRule = <e0fd9950 87366a29 fa6702bf 7e7acc3a 86c2f088 3875c341 81414177 4720eee8>;
            Airline = <f8491ecb 2628a003 143b935b 3d3c291b fac507d8 2339af1b 1ac0fe8b 04b73602>;
            Airport = <09e93c0e fbf1e542 d1428584 30549a84 2e0cb9d3 8b50a508 31807dec d7e5f845>;
            Alliance = <b9b53f23 d5962f3f b7a0a3a5 5ca84d83 61d81f7c 0787ca6a dfdfdf21 733b5e4d>;
            AllianceTier = <6ec8bee0 5d4c62f8 1411eaab b464d783 c6388b12 06506824 f11d6453 a58e509a>;
            Amenity = <86065297 64aff55b b7bfec32 e8e14b74 5d7afa5b 751e760e e37e6294 2e40e26a>;
            Data = <92870bec c4a8794e 293dcbe9 93282d69 cb675039 cb9b9bf6 8dda6359 34697663>;
            Event = <de060947 8ec9f2bb 80e341eb 787e7eec 7cc2a09f 356e511c 7d515ca5 130690fe>;
            FeedItem = <1d0d12fc 82eb532a c1a42ad3 57022129 2c44360e ab5514ce a44d6de0 719ca798>;
            Image = <94e1ad81 4a2aa37b 6a02a52e fb481891 5028fafc 0645de55 7316e5d9 f630ca85>;
            Lounge = <57e5d036 c67f1f9d b3c731a6 4136866e 008684b0 f2ec0620 58e6e56c dbbed4fe>;
            ParseObject = <bfa49e8c 1108961a 49848584 0f2fe83f 082bdc6a 2948e09f 68a84c50 2acb0699>;
            Review = <b423b85c 47d15ee8 bbacbfcf 019fb741 165da2ab 5fa6f087 1975bb31 712bdb64>;
            User = <8451767f db80e10a 15ea83d8 83dc1a2c e89d1699 0b302640 59a23144 61c65be0>;
            Vote = <38d267c9 0c44854e dd01201c b728b906 21fd25cd 8343a416 adf769c6 faef7cb6>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =        (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "222748EF-2F19-4B87-829C-F8171E439430";
        "_NSAutoVacuumLevel" = 2;
    };
    reason = "Can't find model for source store";
}
2014-09-05 02:19:52.404 [948:166846] CoreData: annotation: NSPersistentStoreCoordinator's current model hashes are {
    AccessItem = <c81a9dbd 17033d2e 91d33b1c fc94ab08 bd3619e2 b5fea24d 6881959a f8023dc5>;
    AccessRule = <e0fd9950 87366a29 fa6702bf 7e7acc3a 86c2f088 3875c341 81414177 4720eee8>;
    Airline = <f8491ecb 2628a003 143b935b 3d3c291b fac507d8 2339af1b 1ac0fe8b 04b73602>;
    Airport = <09e93c0e fbf1e542 d1428584 30549a84 2e0cb9d3 8b50a508 31807dec d7e5f845>;
    Alliance = <b9b53f23 d5962f3f b7a0a3a5 5ca84d83 61d81f7c 0787ca6a dfdfdf21 733b5e4d>;
    AllianceTier = <6ec8bee0 5d4c62f8 1411eaab b464d783 c6388b12 06506824 f11d6453 a58e509a>;
    Amenity = <86065297 64aff55b b7bfec32 e8e14b74 5d7afa5b 751e760e e37e6294 2e40e26a>;
    FeedItem = <1d0d12fc 82eb532a c1a42ad3 57022129 2c44360e ab5514ce a44d6de0 719ca798>;
    Image = <94e1ad81 4a2aa37b 6a02a52e fb481891 5028fafc 0645de55 7316e5d9 f630ca85>;
    Lounge = <57e5d036 c67f1f9d b3c731a6 4136866e 008684b0 f2ec0620 58e6e56c dbbed4fe>;
    ParseObject = <bfa49e8c 1108961a 49848584 0f2fe83f 082bdc6a 2948e09f 68a84c50 2acb0699>;
    Review = <b423b85c 47d15ee8 bbacbfcf 019fb741 165da2ab 5fa6f087 1975bb31 712bdb64>;
    User = <8451767f db80e10a 15ea83d8 83dc1a2c e89d1699 0b302640 59a23144 61c65be0>;
    Vote = <38d267c9 0c44854e dd01201c b728b906 21fd25cd 8343a416 adf769c6 faef7cb6>;
}
like image 995
Jlam Avatar asked Sep 05 '14 10:09

Jlam


1 Answers

You have a model, but it's not compatible with the store. What it seems to me is that you made a change to the model without adding a version. With any Core Data migration, you need a source model and the destination model. That is, Core Data needs to know what the original data looks like, and what the new data looks like. From there, Core Data can then deduce (infer) the changes between models for automatic migrations. Since the source model isn't found in this case, and I'm assuming you still have a model that is in your project, it's likely you changed the data model without adding a version. Hopefully, you're using some source control and can revert to the version of the dat model that matches the store. From there, you'll need to 'Add Model Version'. Look for it in one of the Xcode menus. You'll also need to make sure the new version is the current model version for the migration to kick off properly.

And, if you're using MagicalRecord, you can use one of the simple helper methods that migrate data when a store is attached.

like image 95
casademora Avatar answered Oct 04 '22 10:10

casademora