I have an app in which I haven't set the SQLite version in and now I want to upgrade the app but I have some column changes in the new iPA. How can I implement the DB Migration in iOS? I am using FMDB for the database.
Asked
Active
Viewed 581 times
1 Answers
0
Keep a constant which version point to the version increments. Each time the database updates increment the counter.
On app launch call the following code :
DatabaseMigrator *dbMigrator = [[DatabaseMigrator alloc]
initWithDatabaseFile:
[AbstractRepository databaseFilename]];
//for development only - toggle this to force the new database over
//dbMigrator.overwriteDatabase = YES;
[dbMigrator moveDatabaseToUserDirectoryIfNeeded];
[dbMigrator migrateToVersion:CURRENT_SCHEMA_VERSION];
BOOL marked = [FileUtils addSkipBackupAttributeToItemAtURL:[AbstractRepository databasePath]];
if (marked) {
NSLog(@"succesfully Marked do not back up");
} else {
NSLog(@"failed Marked do not back up");
}

yoshiiiiiiii
- 953
- 8
- 20
-
Where to get the DBMigrator class? What to write in it? – Nik Jul 05 '17 at 04:12