ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.85k stars 2.77k forks source link

FMDB/SQLCipher 3.4.2 to 4.1.0 migration issue #736

Open chappanagavendra opened 5 years ago

chappanagavendra commented 5 years ago

Hi ,

I am using FMDB/SQLCipher for encrypting my database. I have an old version of the application running on the 3.4.2 version of SQLCipher. After the i updated pod , now i am trying to install a new update(which is running on the 4.x version of SQLCipher), we got the file is not a database error. I am not able to read the file , its giving database error.

FMDB verion : 2.7.5

Please suggest me

jlcool commented 5 years ago

Yeah, what to do? How to change it to 3.x?

jlcool commented 5 years ago

I think I've found a way.You can try this modification.

s.dependency 'FMDB/SQLCipher' s.dependency 'SQLCipher', '~>3.4.2'

R4N commented 5 years ago

@chappanagavendra @jlcool The default settings have changed in SQLCipher 4, so they will not open a SQLCipher 3 database by default. There's additional information along with migration options/examples here: https://discuss.zetetic.net/t/upgrading-to-sqlcipher-4/3283

Pratik-Sodha commented 5 years ago

I'm facing similar issue. Did anyone found solution ?

  pod 'FMDB/SQLCipher', '~> 2.7'
  pod 'FMDBMigrationManager', '~> 1.4.x'

I'm using above pods. And it's working fine till now with following pod version.

FMDB - 2.7.2 SQLCipher - 3.4.1 FMDBMigrationManager - 1.4.1

After pod update i'm getting error database migration fails.

Any help appreciated.

R4N commented 5 years ago

@Pratik-Sodha

The default encryption settings between major versions of SQLCipher are not compatible out of the box (i.e. you can't open a database created with SQLCipher 3.x using SQLCipher 4.x without migrating it or manually modifying the default encryption settings). You'll need to migrate your 3.x SQLCipher database to use the 4.x encryption settings using PRAGMA cipher_migrate

Pratik-Sodha commented 5 years ago

@R4N Thank you for feedback.

But needed version dependency support into podsepc.

R4N commented 5 years ago

@Pratik-Sodha

I believe you're requesting to add a version to the SQLCipher subspec, is that correct?

The current subspec uses the latest available version of SQLCipher which could include breaking encryption settings changes (if going from one major version to another) as mentioned in this github issue.

Ideally, it should be the responsibility of the developer to handle these migrations within their own application code -- there are recommendations here: https://discuss.zetetic.net/t/upgrading-to-sqlcipher-4/3283/17 from the SQLCipher team with a fairly standard way to perform a migration when necessary with the smallest impact in most scenarios.

That being said, if we did want to cap the SQLCipher subspec major version number and only explicitly bump it to the next major version number, I could issue a PR.

@ccgus I know you don't really use Cocoa Pods, but any thoughts on this? It would basically be a one line change to the podspec but would require explicitly adjusting it when wanting to move to the next major version of SQLCipher -- currently when using pod update you would automatically be moved to the latest version of SQLCipher available (not capped at by major version number)

ccgus commented 5 years ago

@R4N I don't use Cocoa Pods either. If someone wants to send a PR for the change, then I can add it to the mail repo.

WeiXuG-2023 commented 5 years ago

坑爹啊