forked from mirrors/linphone-iphone
fix(MainDb): use a shared timestamp type for sqlite3 and MySql
This commit is contained in:
parent
6cd4752bdf
commit
a1dc06d352
3 changed files with 20 additions and 4 deletions
|
|
@ -123,6 +123,20 @@ string AbstractDb::primaryKeyRefStr (const string &type) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
string AbstractDb::timestampType () const {
|
||||
L_D();
|
||||
|
||||
switch (d->backend) {
|
||||
case Mysql:
|
||||
return " TIMESTAMP";
|
||||
case Sqlite3:
|
||||
return " DATE";
|
||||
}
|
||||
|
||||
L_ASSERT(false);
|
||||
return "";
|
||||
}
|
||||
|
||||
long long AbstractDb::getLastInsertId () const {
|
||||
long long id = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ protected:
|
|||
std::string primaryKeyStr (const std::string &type = "INT") const;
|
||||
std::string primaryKeyRefStr (const std::string &type = "INT") const;
|
||||
|
||||
std::string timestampType () const;
|
||||
|
||||
long long getLastInsertId () const;
|
||||
|
||||
void enableForeignKeys (bool status);
|
||||
|
|
|
|||
|
|
@ -1006,7 +1006,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
"CREATE TABLE IF NOT EXISTS event ("
|
||||
" id" + primaryKeyStr("BIGINT UNSIGNED") + ","
|
||||
" type TINYINT UNSIGNED NOT NULL,"
|
||||
" creation_time TIMESTAMP NOT NULL"
|
||||
" creation_time" + timestampType() + " NOT NULL"
|
||||
") " + charset;
|
||||
|
||||
*session <<
|
||||
|
|
@ -1019,10 +1019,10 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
" local_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + " NOT NULL,"
|
||||
|
||||
// Dialog creation time.
|
||||
" creation_time TIMESTAMP NOT NULL,"
|
||||
" creation_time" + timestampType() + " NOT NULL,"
|
||||
|
||||
// Last event time (call, message...).
|
||||
" last_update_time TIMESTAMP NOT NULL,"
|
||||
" last_update_time" + timestampType() + " NOT NULL,"
|
||||
|
||||
// ConferenceChatRoom, BasicChatRoom, RTT...
|
||||
" capabilities TINYINT UNSIGNED NOT NULL,"
|
||||
|
|
@ -1149,7 +1149,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
" from_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + " NOT NULL,"
|
||||
" to_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + " NOT NULL,"
|
||||
|
||||
" time TIMESTAMP,"
|
||||
" time" + timestampType() + " ,"
|
||||
|
||||
// See: https://tools.ietf.org/html/rfc5438#section-6.3
|
||||
" imdn_message_id VARCHAR(255) NOT NULL,"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue