From b1d1ccdbc8744fb0a102ab30e8f8016a654ce341 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 10 Sep 2020 09:39:06 +0100 Subject: [PATCH] allow duplicate stream ids in the peeks table --- syncapi/storage/postgres/peeks_table.go | 5 +++-- syncapi/storage/sqlite3/peeks_table.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/syncapi/storage/postgres/peeks_table.go b/syncapi/storage/postgres/peeks_table.go index 23981eeab..f0c63fdb3 100644 --- a/syncapi/storage/postgres/peeks_table.go +++ b/syncapi/storage/postgres/peeks_table.go @@ -27,13 +27,14 @@ import ( const peeksSchema = ` CREATE TABLE IF NOT EXISTS syncapi_peeks ( - id BIGINT PRIMARY KEY DEFAULT nextval('syncapi_stream_id'), + id BIGINT DEFAULT nextval('syncapi_stream_id'), room_id TEXT NOT NULL, user_id TEXT NOT NULL, device_id TEXT NOT NULL, deleted BOOL NOT NULL DEFAULT false, -- When the peek was created in UNIX epoch ms. - creation_ts BIGINT NOT NULL + creation_ts BIGINT NOT NULL, + UNIQUE(room_id, user_id, device_id) ); CREATE INDEX IF NOT EXISTS syncapi_peeks_room_id_idx ON syncapi_peeks(room_id); diff --git a/syncapi/storage/sqlite3/peeks_table.go b/syncapi/storage/sqlite3/peeks_table.go index 409b03019..4dc336a12 100644 --- a/syncapi/storage/sqlite3/peeks_table.go +++ b/syncapi/storage/sqlite3/peeks_table.go @@ -27,13 +27,14 @@ import ( const peeksSchema = ` CREATE TABLE IF NOT EXISTS syncapi_peeks ( - id INTEGER PRIMARY KEY, + id INTEGER, room_id TEXT NOT NULL, user_id TEXT NOT NULL, device_id TEXT NOT NULL, deleted BOOL NOT NULL DEFAULT false, -- When the peek was created in UNIX epoch ms. - creation_ts INTEGER NOT NULL + creation_ts INTEGER NOT NULL, + UNIQUE(room_id, user_id, device_id) ); CREATE INDEX IF NOT EXISTS syncapi_peeks_room_id_idx ON syncapi_peeks(room_id);