From 82f04ddb29e24062f951a849fdb19a26cce5fc4d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 21 Nov 2017 15:39:08 +0100 Subject: [PATCH] feat(MainDb): enforce chat_room table, add unique and not null constraints on peer/local ids --- src/db/main-db.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 5a9a1826f..8da8c2517 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -710,9 +710,9 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), " id" + primaryKeyStr("BIGINT UNSIGNED") + "," // Server (for conference) or user sip address. - " peer_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + "," + " peer_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + " NOT NULL," - " local_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + "," + " local_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + " NOT NULL," // Dialog creation date. " creation_date DATE NOT NULL," @@ -721,13 +721,15 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), " last_update_date DATE NOT NULL," // ConferenceChatRoom, BasicChatRoom, RTT... - " capabilities TINYINT UNSIGNED," + " capabilities TINYINT UNSIGNED NOT NULL," // Chatroom subject. " subject VARCHAR(255)," " last_notify_id INT UNSIGNED," + " UNIQUE (peer_sip_address_id, local_sip_address_id)," + " FOREIGN KEY (peer_sip_address_id)" " REFERENCES sip_address(id)" " ON DELETE CASCADE,"