static NSDate* tmpStartData ;
-(BOOL)reCreateNewSqlAndMoveOldData_chatTable{
@synchronized(self)
{
NSString* temp_chat_table = [NSString stringWithFormat:@"temp_chat_table"];
BOOL result = [_userDatabase executeUpdate:[NSString stringWithFormat:@"alter table %@ rename to %@",tab_chat,temp_chat_table]];
if (result) {
if( [self createChatTable]){
if ( [_userDatabase executeUpdate:[NSString stringWithFormat:@"insert into %@ (msgkey, timestamp, sessionKey, sessionID, sessionType, groupType, fromeID, toID, seq, state,\
contentType, content, dataPath, extend, replace, imageWidth, imageHeight\
) select msgkey, timestamp, sessionKey, sessionID, sessionType, groupType, fromeID, toID, seq, state,\
contentType, content, dataPath, extend, replace, imageWidth, imageHeight\
from %@",tab_chat,temp_chat_table]]) {
// if ( [_userDatabase executeUpdate:[NSString stringWithFormat:@"insert into %@ select* from %@",tab_chat,temp_chat_table]]) {
NSLog(lls(@"升级成功啦~"));
}
else{
NSLog(lls(@"升级失败啦!!"));
}
[_userDatabase executeUpdate:[NSString stringWithFormat:@"drop table if exists %@",temp_chat_table]];
return YES;
}
}
return NO;
}
}
数据库迁移
最新推荐文章于 2024-07-26 09:40:31 发布