Convert postgres queries to be sqlite queries

This commit is contained in:
Kegan Dougal 2020-07-15 11:27:15 +01:00
parent 6ab49ac863
commit 0f6a574221
2 changed files with 4 additions and 4 deletions

View file

@ -32,14 +32,14 @@ CREATE TABLE IF NOT EXISTS keyserver_device_keys (
ts_added_secs BIGINT NOT NULL, ts_added_secs BIGINT NOT NULL,
key_json TEXT NOT NULL, key_json TEXT NOT NULL,
-- Clobber based on tuple of user/device. -- Clobber based on tuple of user/device.
CONSTRAINT keyserver_device_keys_unique UNIQUE (user_id, device_id) UNIQUE (user_id, device_id)
); );
` `
const upsertDeviceKeysSQL = "" + const upsertDeviceKeysSQL = "" +
"INSERT INTO keyserver_device_keys (user_id, device_id, ts_added_secs, key_json)" + "INSERT INTO keyserver_device_keys (user_id, device_id, ts_added_secs, key_json)" +
" VALUES ($1, $2, $3, $4)" + " VALUES ($1, $2, $3, $4)" +
" ON CONFLICT ON CONSTRAINT keyserver_device_keys_unique" + " ON CONFLICT (user_id, device_id)" +
" DO UPDATE SET key_json = $4" " DO UPDATE SET key_json = $4"
const selectDeviceKeysSQL = "" + const selectDeviceKeysSQL = "" +

View file

@ -36,14 +36,14 @@ CREATE TABLE IF NOT EXISTS keyserver_one_time_keys (
ts_added_secs BIGINT NOT NULL, ts_added_secs BIGINT NOT NULL,
key_json TEXT NOT NULL, key_json TEXT NOT NULL,
-- Clobber based on 4-uple of user/device/key/algorithm. -- Clobber based on 4-uple of user/device/key/algorithm.
CONSTRAINT keyserver_one_time_keys_unique UNIQUE (user_id, device_id, key_id, algorithm) UNIQUE (user_id, device_id, key_id, algorithm)
); );
` `
const upsertKeysSQL = "" + const upsertKeysSQL = "" +
"INSERT INTO keyserver_one_time_keys (user_id, device_id, key_id, algorithm, ts_added_secs, key_json)" + "INSERT INTO keyserver_one_time_keys (user_id, device_id, key_id, algorithm, ts_added_secs, key_json)" +
" VALUES ($1, $2, $3, $4, $5, $6)" + " VALUES ($1, $2, $3, $4, $5, $6)" +
" ON CONFLICT ON CONSTRAINT keyserver_one_time_keys_unique" + " ON CONFLICT (user_id, device_id, key_id, algorithm)" +
" DO UPDATE SET key_json = $6" " DO UPDATE SET key_json = $6"
const selectKeysSQL = "" + const selectKeysSQL = "" +