update db: insert special seller

This commit is contained in:
Martin Brodbeck 2018-08-07 07:57:47 +02:00
parent 1ee1252c46
commit 3a40f586fa
2 changed files with 13 additions and 1 deletions

View file

@ -101,6 +101,15 @@ void Database::createNew()
endTransaction(); endTransaction();
} }
void Database::updateDbToVer2()
{
beginTransaction();
exec("INSERT INTO sellers (id, seller_no, first_name, last_name, num_offered_articles) VALUES "
"('11111111-1111-1111-1111-111111111111', 0, 'Sonderkonto', 'Sonderkonto', 0)");
exec("UPDATE kima2 SET version = 2");
endTransaction();
}
void Database::init() void Database::init()
{ {
const int errCode = sqlite3_open(dbname_.c_str(), &db_); const int errCode = sqlite3_open(dbname_.c_str(), &db_);
@ -117,7 +126,9 @@ void Database::init()
case 0: case 0:
createNew(); createNew();
break; break;
// perhaps handle upgrades for db schema here... case 1:
updateDbToVer2();
break;
default: default:
// Do nothing because we are up-to-date. // Do nothing because we are up-to-date.
break; break;

View file

@ -34,6 +34,7 @@ class Database
void createNew(); void createNew();
int getVersion(); int getVersion();
unsigned int storeArticles(std::vector<Article*> articles); unsigned int storeArticles(std::vector<Article*> articles);
void updateDbToVer2();
}; };
#endif // DATABASE_H #endif // DATABASE_H