|
|
@@ -1001,8 +1001,18 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
if (rename) {
|
|
|
|
|
|
- NSString *rename_model_to_product = [NSString stringWithFormat:@"alter %@ rename to %@;",table,column_str_or_new_table_name];
|
|
|
- [self execSql:rename_model_to_product db:db];
|
|
|
+ NSString *check_table_exist = [NSString stringWithFormat:@"SELECT count(*) FROM sqlite_master WHERE type='table' AND name='%@';",column_str_or_new_table_name];
|
|
|
+ __block BOOL exist = NO;
|
|
|
+ [self jk_query:check_table_exist db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ int ct = sqlite3_column_int(stmt, 0);
|
|
|
+ exist = ct ? YES : 0;
|
|
|
+ }];
|
|
|
+
|
|
|
+ if (!exist) {
|
|
|
+ NSString *rename_model_to_product = [NSString stringWithFormat:@"alter %@ rename to %@;",table,column_str_or_new_table_name];
|
|
|
+ [self execSql:rename_model_to_product db:db];
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|