Commit 77b35ea4 authored by Ronan's avatar Ronan

feat(EventsDb): supports message file info

parent 3d283b29
...@@ -184,13 +184,18 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} ...@@ -184,13 +184,18 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
*session << *session <<
"CREATE TABLE IF NOT EXISTS message_event (" "CREATE TABLE IF NOT EXISTS message_event ("
" id" + primaryKeyAutoIncrementStr() + "," " id" + primaryKeyAutoIncrementStr() + ","
" event_id INT UNSIGNED NOT NULL,"
" dialog_id INT UNSIGNED NOT NULL," " dialog_id INT UNSIGNED NOT NULL,"
" state_id TINYINT UNSIGNED NOT NULL," " state_id TINYINT UNSIGNED NOT NULL,"
" direction_id TINYINT UNSIGNED NOT NULL," " direction_id TINYINT UNSIGNED NOT NULL,"
" imdn_message_id VARCHAR(255) NOT NULL," // See: https://tools.ietf.org/html/rfc5438#section-6.3 " imdn_message_id VARCHAR(255) NOT NULL," // See: https://tools.ietf.org/html/rfc5438#section-6.3
" content_type VARCHAR(255) NOT NULL," // Content type of text. (Html or text for example.)
" is_secured BOOLEAN NOT NULL," " is_secured BOOLEAN NOT NULL,"
" content_type VARCHAR(255) NOT NULL," // Content type of text. (Html or text for example.)
" text TEXT,"
" app_data VARCHAR(2048)," // App user data. " app_data VARCHAR(2048)," // App user data.
" FOREIGN KEY (event_id)"
" REFERENCES event(id)"
" ON DELETE CASCADE,"
" FOREIGN KEY (dialog_id)" " FOREIGN KEY (dialog_id)"
" REFERENCES dialog(id)" " REFERENCES dialog(id)"
" ON DELETE CASCADE," " ON DELETE CASCADE,"
...@@ -202,6 +207,21 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} ...@@ -202,6 +207,21 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
" ON DELETE CASCADE" " ON DELETE CASCADE"
")"; ")";
*session <<
"CREATE TABLE IF NOT EXISTS message_file_info ("
" id" + primaryKeyAutoIncrementStr() + ","
" message_id INT UNSIGNED NOT NULL,"
" content_type VARCHAR(255) NOT NULL," // File content type.
" name VARCHAR(255) NOT NULL," // File name.
" size INT UNSIGNED NOT NULL," // File size.
" url VARCHAR(255) NOT NULL," // File url.
" key VARCHAR(4096),"
" key_size INT UNSIGNED,"
" FOREIGN KEY (message_id)"
" REFERENCES message(id)"
" ON DELETE CASCADE"
")";
{ {
string query = getBackend() == Mysql string query = getBackend() == Mysql
? "INSERT INTO event_type (id, value)" ? "INSERT INTO event_type (id, value)"
...@@ -252,7 +272,7 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} ...@@ -252,7 +272,7 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
bool EventsDb::addEvent (const EventLog &eventLog) { bool EventsDb::addEvent (const EventLog &eventLog) {
if (!isConnected()) { if (!isConnected()) {
lWarning() << "Unable to add event. Not connected."; lWarning() << "Unable to add event. Not connected.";
return false; return false;
} }
// TODO. // TODO.
......
No preview for this file type
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