Skip to content

Commit

Permalink
feat(desktop-notifications): add new table for session management
Browse files Browse the repository at this point in the history
This feature introduces a new session table which is needed by the `icinga-notifications-web` project. It stores the current authenticated sessions into the table which allows the background daemon (php-based) to validate a connection and its corresponding browser to an authenticated session.
Read #118 for more information about this addition.
  • Loading branch information
ncosta-ic committed Nov 29, 2023
1 parent b54cec5 commit 11f4cfb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions schema/pgsql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,32 @@ CREATE TABLE incident_history (
CONSTRAINT pk_incident_history PRIMARY KEY (id),
FOREIGN KEY (incident_id, rule_escalation_id) REFERENCES incident_rule_escalation_state(incident_id, rule_escalation_id)
);

CREATE OR REPLACE FUNCTION now_extended() RETURNS bigint
LANGUAGE SQL AS
$$
SELECT ((EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1_000) :: bigint);
$$;

CREATE TABLE session
(
id VARCHAR(256) NOT NULL,
username VARCHAR(254) NOT NULL,
device_id VARCHAR(8) NOT NULL,
authenticated_at bigint NOT NULL DEFAULT now_extended(),

CONSTRAINT pk_id_username_device PRIMARY KEY (id, username, device_id)
);

CREATE INDEX idx_id ON session (
id
);

CREATE INDEX idx_authenticated ON session (
authenticated_at
);

CREATE INDEX idx_username_device ON session (
username,
device_id
);

0 comments on commit 11f4cfb

Please sign in to comment.