From 3d4f43a051cfefda740688dec6a5f50572b3a668 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 3 Jan 2021 12:47:12 +0000 Subject: [PATCH] add NOT NULL constraints --- .../Messaging/Agent/Store/SQLite/Schema.hs | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs b/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs index e7a0b2d9e..47f0e255d 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs @@ -12,8 +12,8 @@ servers = [s| CREATE TABLE IF NOT EXISTS servers ( server_id INTEGER PRIMARY KEY, - host_address TEXT, - port INT, + host_address TEXT NOT NULL, + port INT NOT NULL, key_hash BLOB, UNIQUE (host_address, port) ) @@ -25,15 +25,17 @@ recipientQueues = [s| CREATE TABLE IF NOT EXISTS recipient_queues ( recipient_queue_id INTEGER PRIMARY KEY, - server_id INTEGER REFERENCES servers(server_id), - rcv_id BLOB, - rcv_private_key BLOB, + server_id INTEGER REFERENCES servers(server_id) NOT NULL, + rcv_id BLOB NOT NULL, + rcv_private_key BLOB NOT NULL, snd_id BLOB, snd_key BLOB, - decrypt_key BLOB, + decrypt_key BLOB NOT NULL, verify_key BLOB, - status TEXT, - ack_mode INTEGER + status TEXT NOT NULL, + ack_mode INTEGER NOT NULL, + UNIQUE (server_id, rcv_id), + UNIQUE (server_id, snd_id) ) |] @@ -42,13 +44,13 @@ senderQueues = [s| CREATE TABLE IF NOT EXISTS sender_queues ( sender_queue_id INTEGER PRIMARY KEY, - server_id INTEGER REFERENCES servers(server_id), - snd_id BLOB, - snd_private_key BLOB, - encrypt_key BLOB, - sign_key BLOB, - status TEXT, - ack_mode INTEGER + server_id INTEGER REFERENCES servers(server_id) NOT NULL, + snd_id BLOB NOT NULL, + snd_private_key BLOB NOT NULL, + encrypt_key BLOB NOT NULL, + sign_key BLOB NOT NULL, + status TEXT NOT NULL, + ack_mode INTEGER NOT NULL ) |] @@ -69,11 +71,11 @@ messages = CREATE TABLE IF NOT EXISTS messages ( message_id INTEGER PRIMARY KEY, conn_alias TEXT REFERENCES connections(conn_alias), - agent_msg_id INTEGER, - timestamp TEXT, - message TEXT, - direction TEXT, - msg_status TEXT + agent_msg_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + message BLOB NOT NULL, + direction TEXT NOT NULL, + msg_status TEXT NOT NULL ) |]