grasmeyer/ZumeroIncrementalStore

migration failing because of foreign keys without cascade rules, snippet for fix

Opened this issue · 0 comments

Some migrations were failing for me because of foreign keys constraints,
so turning these test off (and possibly then on after finished migration) did the job,
so if anyone is having same issues it can be helped with code like :
(The way the migration works it is supposed to fail during migration without cascade rules as it is copying tables one by one, even though they may be referencing not-yet-copied tables -> causing fail if cascade rules are not set)

int newForeignKeysPolicy = 0;
NSString *string = [NSString stringWithFormat:@"PRAGMA foreign_keys = %d;", newForeignKeysPolicy];
sqlite3_stmt *statement = [self preparedStatementForQuery:string];
sqlite3_step(statement);