mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-25 20:44:49 +00:00
add queries drafts for insertion of server, queue, connection
This commit is contained in:
@@ -7,3 +7,58 @@ import qualified Database.SQLite.Simple as DB
|
||||
-- createRcvConn conn connAlias q = do
|
||||
-- id <- query conn "INSERT ..."
|
||||
-- query conn "INSERT ..."
|
||||
|
||||
|
||||
|
||||
-- sqlite queries to create server, queue and connection
|
||||
|
||||
-- *** step 1 - insert server before create request to server
|
||||
-- ! "INSERT OR REPLACE INTO" with autoincrement apparently would change id,
|
||||
-- ! so going with "ON CONFLICT UPDATE" here
|
||||
|
||||
-- INSERT INTO servers (host_address, port, key_hash)
|
||||
-- VALUES ({host_address}, {port}, {key_hash})
|
||||
-- ON CONFLICT(host_address, port) DO UPDATE SET
|
||||
-- host_address=excluded.host_address,
|
||||
-- port=excluded.port,
|
||||
-- key_hash=excluded.key_hash;
|
||||
|
||||
-- *** step 2 - insert queue and connection after server's response
|
||||
-- BEGIN TRANSACTION;
|
||||
|
||||
-- INSERT INTO recipient_queues (
|
||||
-- server_id,
|
||||
-- rcv_id,
|
||||
-- rcv_private_key,
|
||||
-- snd_id,
|
||||
-- snd_key,
|
||||
-- decrypt_key,
|
||||
-- verify_key,
|
||||
-- status,
|
||||
-- ack_mode
|
||||
-- )
|
||||
-- VALUES (
|
||||
-- {server_id},
|
||||
-- {rcv_id},
|
||||
-- {rcv_private_key},
|
||||
-- {snd_id},
|
||||
-- {snd_key},
|
||||
-- {decrypt_key},
|
||||
-- {verify_key},
|
||||
-- {status},
|
||||
-- {ack_mode}
|
||||
-- );
|
||||
|
||||
-- INSERT INTO connections (
|
||||
-- conn_alias,
|
||||
-- recipient_queue_id,
|
||||
-- sender_queue_id
|
||||
-- )
|
||||
-- VALUES (
|
||||
-- {conn_alias},
|
||||
-- {recipient_queue_id},
|
||||
-- {sender_queue_id}
|
||||
-- );
|
||||
|
||||
-- COMMIT;
|
||||
-- ***
|
||||
|
||||
@@ -12,8 +12,11 @@ servers =
|
||||
[s|
|
||||
CREATE TABLE IF NOT EXISTS servers
|
||||
( server_id INTEGER PRIMARY KEY,
|
||||
host_address TEXT
|
||||
)
|
||||
host_address TEXT,
|
||||
port INT,
|
||||
key_hash BLOB,
|
||||
UNIQUE (host_address, port)
|
||||
)
|
||||
|]
|
||||
|
||||
-- TODO unique constraints on (server_id, rcv_id) and (server_id, snd_id)
|
||||
|
||||
Reference in New Issue
Block a user