allow duplicate stream ids in the peeks table

This commit is contained in:
Matthew Hodgson 2020-09-10 09:39:06 +01:00
parent 8cec7e029d
commit b1d1ccdbc8
2 changed files with 6 additions and 4 deletions

View file

@ -27,13 +27,14 @@ import (
const peeksSchema = ` const peeksSchema = `
CREATE TABLE IF NOT EXISTS syncapi_peeks ( 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, room_id TEXT NOT NULL,
user_id TEXT NOT NULL, user_id TEXT NOT NULL,
device_id TEXT NOT NULL, device_id TEXT NOT NULL,
deleted BOOL NOT NULL DEFAULT false, deleted BOOL NOT NULL DEFAULT false,
-- When the peek was created in UNIX epoch ms. -- 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); CREATE INDEX IF NOT EXISTS syncapi_peeks_room_id_idx ON syncapi_peeks(room_id);

View file

@ -27,13 +27,14 @@ import (
const peeksSchema = ` const peeksSchema = `
CREATE TABLE IF NOT EXISTS syncapi_peeks ( CREATE TABLE IF NOT EXISTS syncapi_peeks (
id INTEGER PRIMARY KEY, id INTEGER,
room_id TEXT NOT NULL, room_id TEXT NOT NULL,
user_id TEXT NOT NULL, user_id TEXT NOT NULL,
device_id TEXT NOT NULL, device_id TEXT NOT NULL,
deleted BOOL NOT NULL DEFAULT false, deleted BOOL NOT NULL DEFAULT false,
-- When the peek was created in UNIX epoch ms. -- 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); CREATE INDEX IF NOT EXISTS syncapi_peeks_room_id_idx ON syncapi_peeks(room_id);