Commit a1dc06d3 authored by Ronan's avatar Ronan
Browse files

fix(MainDb): use a shared timestamp type for sqlite3 and MySql

parent 6cd4752b
......@@ -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,"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment