Avoid error messages "table already exists" in RsDataService::initialise by using "IF NOT EXISTS"

This commit is contained in:
thunder2 2015-08-10 13:27:46 +02:00
parent 783465bc89
commit ab538c6d28

View File

@ -216,7 +216,7 @@ void RsDataService::initialise(){
// create table for msg data // create table for msg data
mDb->execSQL("CREATE TABLE " + MSG_TABLE_NAME + "(" + mDb->execSQL("CREATE TABLE IF NOT EXISTS " + MSG_TABLE_NAME + "(" +
KEY_MSG_ID + " TEXT PRIMARY KEY," + KEY_MSG_ID + " TEXT PRIMARY KEY," +
KEY_GRP_ID + " TEXT," + KEY_GRP_ID + " TEXT," +
KEY_NXS_FLAGS + " INT," + KEY_NXS_FLAGS + " INT," +
@ -238,7 +238,7 @@ void RsDataService::initialise(){
KEY_NXS_FILE_LEN + " INT);"); KEY_NXS_FILE_LEN + " INT);");
// create table for grp data // create table for grp data
mDb->execSQL("CREATE TABLE " + GRP_TABLE_NAME + "(" + mDb->execSQL("CREATE TABLE IF NOT EXISTS " + GRP_TABLE_NAME + "(" +
KEY_GRP_ID + " TEXT PRIMARY KEY," + KEY_GRP_ID + " TEXT PRIMARY KEY," +
KEY_TIME_STAMP + " INT," + KEY_TIME_STAMP + " INT," +
KEY_NXS_FILE + " TEXT," + KEY_NXS_FILE + " TEXT," +
@ -268,7 +268,7 @@ void RsDataService::initialise(){
KEY_GRP_REP_CUTOFF + " INT," + KEY_GRP_REP_CUTOFF + " INT," +
KEY_SIGN_SET + " BLOB);"); KEY_SIGN_SET + " BLOB);");
mDb->execSQL("CREATE TRIGGER " + GRP_LAST_POST_UPDATE_TRIGGER + mDb->execSQL("CREATE TRIGGER IF NOT EXISTS " + GRP_LAST_POST_UPDATE_TRIGGER +
" INSERT ON " + MSG_TABLE_NAME + " INSERT ON " + MSG_TABLE_NAME +
std::string(" BEGIN ") + std::string(" BEGIN ") +
" UPDATE " + GRP_TABLE_NAME + " SET " + KEY_GRP_LAST_POST + "= new." " UPDATE " + GRP_TABLE_NAME + " SET " + KEY_GRP_LAST_POST + "= new."