mercredi 25 mars 2015

How to migrate *.sqlite database via FMDBMigrationManager?

I'm using FMDB IOS framework to manage my sqlite database.


But now I have second version of my database, so I need to update my sqlite file (on devices with installed app)


Here is my steps: (database is in Application Support/db/db.sqlite )



  1. create second . sqlite file (named "2_db.sqlite") and copy it into my main Bundle


  2. Use this code on every start



    -(void)migrateWithDBAtPath:(NSString *)dbPath {
    FMDBMigrationManager *manager = [FMDBMigrationManager managerWithDatabaseAtPath:dbPath migrationsBundle:[NSBundle mainBundle]];
    NSError *error = nil;
    BOOL success = [manager migrateDatabaseToVersion:UINT64_MAX progress:nil error:&error];
    }



dbPath is .../Library/Application Support/db/db.sqlite


But after this steps I have no migration and 0 pendingVersions in migrateDatabaseToVersion:progress:error:


What am I doing wrong? Thanks.


Aucun commentaire:

Enregistrer un commentaire