Server changes/Sonarr
This commit is contained in:
@@ -10,12 +10,28 @@ CREATE TABLE IF NOT EXISTS sessions (
|
||||
username TEXT NOT NULL,
|
||||
server_id TEXT NOT NULL DEFAULT '',
|
||||
device_id TEXT NOT NULL DEFAULT '',
|
||||
device_name TEXT NOT NULL DEFAULT 'Memby TV',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
last_seen_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
ALTER TABLE sessions ADD COLUMN IF NOT EXISTS device_name TEXT NOT NULL DEFAULT 'Memby TV';
|
||||
|
||||
-- Older builds could create more than one token for the same physical TV. Keep the most
|
||||
-- recently used row before adding the identity constraint.
|
||||
DELETE FROM sessions older
|
||||
USING sessions newer
|
||||
WHERE older.emby_user_id = newer.emby_user_id
|
||||
AND older.device_id = newer.device_id
|
||||
AND (
|
||||
older.last_seen_at < newer.last_seen_at
|
||||
OR (older.last_seen_at = newer.last_seen_at AND older.token_hash < newer.token_hash)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sessions_emby_user_idx ON sessions (emby_user_id);
|
||||
CREATE INDEX IF NOT EXISTS sessions_last_seen_idx ON sessions (last_seen_at);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS sessions_user_device_idx
|
||||
ON sessions (emby_user_id, device_id);
|
||||
|
||||
-- The imported library.
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user