|
|
@@ -724,33 +724,49 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
/*************************ALTER TABLE From V1.4 to V1.5************************************/
|
|
|
|
|
|
- NSString *rename_model_to_product = @"alter model rename to product";
|
|
|
- [self execSql:rename_model_to_product db:db];
|
|
|
+ [self alterTable:@"model" columns:@"product" rename:YES db:db];
|
|
|
|
|
|
- if (![self checkForField:@"product" field:@"has_bundle" db:db]) {
|
|
|
-
|
|
|
- }
|
|
|
+ [self alterTable:@"product" columns:@"has_bundle integer,is_active integer,item_id integer" rename:NO db:db];
|
|
|
|
|
|
- if( ![self checkForField:@"offline_login" field:@"sales_code" db:db])
|
|
|
- {
|
|
|
- NSString* alter_search_history = @"ALTER TABLE offline_login ADD sales_code text";
|
|
|
- [self execSql:alter_search_history db:db];
|
|
|
- }
|
|
|
- if( ![self checkForField:@"offline_login" field:@"can_update_contact_info" db:db])
|
|
|
- {
|
|
|
- NSString* alter_search_history = @"ALTER TABLE offline_login ADD can_update_contact_info integer";
|
|
|
- [self execSql:alter_search_history db:db];
|
|
|
- }
|
|
|
- if( ![self checkForField:@"offline_contact" field:@"sync_data" db:db])
|
|
|
- {
|
|
|
- NSString* alter_search_history = @"ALTER TABLE offline_contact ADD sync_data text";
|
|
|
- [self execSql:alter_search_history db:db];
|
|
|
- }
|
|
|
- if( ![self checkForField:@"model_image" field:@"picture_id" db:db])
|
|
|
- {
|
|
|
- NSString* alter_search_history = @"ALTER TABLE model_image ADD picture_id integer";
|
|
|
- [self execSql:alter_search_history db:db];
|
|
|
- }
|
|
|
+ [self alterTable:@"model_image" columns:@"item_id integer,picture_id integer" rename:NO db:db];
|
|
|
+
|
|
|
+ [self alterTable:@"model_price" columns:@"item_id integer" rename:NO db:db];
|
|
|
+
|
|
|
+ [self alterTable:@"offline_cart" columns:@"orderitem_id integer,item_id integer,str_price text,item_count integer,line_note text,bundle_item text,type integer,create_timer timestamp default (datetime('now', 'localtime'))" rename:NO db:db];
|
|
|
+
|
|
|
+ [self alterTable:@"offline_contact" columns:@"is_active integer,sync_data text" rename:NO db:db];
|
|
|
+
|
|
|
+ [self alterTable:@"offline_login" columns:@"can_update_contact_info integer,sales_code text" rename:NO db:db];
|
|
|
+
|
|
|
+ [self alterTable:@"wishlist" columns:@"qty integer,create_time timestamp default (datetime('now', 'localtime'))" rename:NO db:db];
|
|
|
+
|
|
|
+// NSString *rename_model_to_product = @"alter model rename to product";
|
|
|
+// [self execSql:rename_model_to_product db:db];
|
|
|
+//
|
|
|
+// if (![self checkForField:@"product" field:@"has_bundle" db:db]) {
|
|
|
+//// [self];
|
|
|
+// }
|
|
|
+//
|
|
|
+// if( ![self checkForField:@"offline_login" field:@"sales_code" db:db])
|
|
|
+// {
|
|
|
+// NSString* alter_search_history = @"ALTER TABLE offline_login ADD sales_code text";
|
|
|
+// [self execSql:alter_search_history db:db];
|
|
|
+// }
|
|
|
+// if( ![self checkForField:@"offline_login" field:@"can_update_contact_info" db:db])
|
|
|
+// {
|
|
|
+// NSString* alter_search_history = @"ALTER TABLE offline_login ADD can_update_contact_info integer";
|
|
|
+// [self execSql:alter_search_history db:db];
|
|
|
+// }
|
|
|
+// if( ![self checkForField:@"offline_contact" field:@"sync_data" db:db])
|
|
|
+// {
|
|
|
+// NSString* alter_search_history = @"ALTER TABLE offline_contact ADD sync_data text";
|
|
|
+// [self execSql:alter_search_history db:db];
|
|
|
+// }
|
|
|
+// if( ![self checkForField:@"model_image" field:@"picture_id" db:db])
|
|
|
+// {
|
|
|
+// NSString* alter_search_history = @"ALTER TABLE model_image ADD picture_id integer";
|
|
|
+// [self execSql:alter_search_history db:db];
|
|
|
+// }
|
|
|
|
|
|
/**********************************************************************************************/
|
|
|
|
|
|
@@ -981,6 +997,31 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
#pragma mark - JK
|
|
|
|
|
|
++ (void)alterTable:(NSString *)table columns:(NSString *)column_str_or_new_table_name rename:(BOOL)rename db:(sqlite3 *)db {
|
|
|
+
|
|
|
+ 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];
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ NSArray *columns = [column_str_or_new_table_name componentsSeparatedByString:@","];
|
|
|
+ for (NSString *column in columns) {
|
|
|
+
|
|
|
+ NSString *name = [[column componentsSeparatedByString:@" "] firstObject];
|
|
|
+// NSString *type = [[column componentsSeparatedByString:@" "] lastObject];
|
|
|
+
|
|
|
+ if( ![self checkForField:table field:name db:db])
|
|
|
+ {
|
|
|
+ NSString* alter_sql = [NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN %@;",table,column];
|
|
|
+ [self execSql:alter_sql db:db];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+ (NSDictionary *)jk_query:(NSString *)sql completion:(queryBlock)block {
|
|
|
|
|
|
return [self jk_query:sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|