project-imas / encrypted-core-data

v2.0 - iOS Core Data encrypted SQLite store using SQLCipher
Other
785 stars 236 forks source link

Issue with lightweight immigration. #321

Open StevenAppJob opened 5 years ago

StevenAppJob commented 5 years ago

Hi, We are using this EncryptedStore many years, and we didn't update the library until now, only we updated sqlite library, the problem we have now, when I do lightweight immigration, the add persistent return nil and error nil also. I tried to update the library, when I update the library the immigration works but the first time when I update, I lose all my data in core-data. Is there away to update my library and not lose all my data?

Thanks

ankitthakur commented 4 years ago

Hi @StevenAppJob, I had faced DB migration issue. I am using latest version of pods. I want to confirm, if you are doing DB migration in below way, it worked for me:

let configuration = EncryptedStoreFileManagerConfiguration()
            configuration.fileManager = FileManager.default
            configuration.databaseURL = persistentStoreURL
            configuration.bundle = Bundle(for: type(of: self))

            let options:[AnyHashable:Any] = [EncryptedStorePassphraseKey: dbPassword as Any,
                                       EncryptedStoreDatabaseLocation: description as Any,
                                       NSMigratePersistentStoresAutomaticallyOption: true as Any,
                                       NSInferMappingModelAutomaticallyOption: true as Any,
                                       EncryptedStoreFileManagerOption: EncryptedStoreFileManager(configuration: configuration) as Any,
                                       EncryptedStoreCacheSize: 5000]
            coordinator = EncryptedStore.make(options: options,
                                              managedObjectModel: managedObjectModel)
StevenAppJob commented 4 years ago

Thanks @ankitthakur, I will try it and let you know..

StevenAppJob commented 4 years ago

Hi @ankitthakur,

The code above, is it inside the EncryotedStore Class?