From b6b4a755cd888fc1f54f8edffb0eeb1255355863 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 29 May 2024 11:22:08 +0200 Subject: [PATCH] schema.sql, 025.sql: make style consistent Mainly adapt spacing and character case to be consistent with the rest. Also do the CREATE EXTENSION at the top of the schema file, it may be used elsewhere in the future as well. One functional change: rename the primary key constraint to be consistent with pk_${table_name} used in the rest of the file. --- schema/pgsql/schema.sql | 23 +++++++++-------------- schema/pgsql/upgrades/025.sql | 19 +++++++------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/schema/pgsql/schema.sql b/schema/pgsql/schema.sql index fe692df3..2d5e3ce2 100644 --- a/schema/pgsql/schema.sql +++ b/schema/pgsql/schema.sql @@ -1,3 +1,5 @@ +CREATE EXTENSION IF NOT EXISTS citext; + CREATE TYPE boolenum AS ENUM ( 'n', 'y' ); CREATE TYPE incident_history_event_type AS ENUM ( -- Order to be honored for events with identical microsecond timestamps. @@ -318,20 +320,13 @@ CREATE TABLE incident_history ( CREATE INDEX idx_incident_history_time_type ON incident_history(time, type); COMMENT ON INDEX idx_incident_history_time_type IS 'Incident History ordered by time/type'; -CREATE EXTENSION IF NOT EXISTS citext; - -CREATE TABLE browser_session -( - php_session_id VARCHAR(256) NOT NULL, - username CITEXT NOT NULL, - user_agent TEXT NOT NULL, - authenticated_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000), +CREATE TABLE browser_session ( + php_session_id varchar(256) NOT NULL, + username citext NOT NULL, + user_agent text NOT NULL, + authenticated_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000), - CONSTRAINT pk_session PRIMARY KEY (php_session_id, username, user_agent) + CONSTRAINT pk_browser_session PRIMARY KEY (php_session_id, username, user_agent) ); -CREATE INDEX browser_session_authenticated_at_idx - ON browser_session ( - authenticated_at - ) -; +CREATE INDEX browser_session_authenticated_at_idx ON browser_session (authenticated_at); diff --git a/schema/pgsql/upgrades/025.sql b/schema/pgsql/upgrades/025.sql index f1e8994c..a28376d9 100644 --- a/schema/pgsql/upgrades/025.sql +++ b/schema/pgsql/upgrades/025.sql @@ -1,17 +1,12 @@ CREATE EXTENSION IF NOT EXISTS citext; -CREATE TABLE browser_session -( - php_session_id VARCHAR(256) NOT NULL, - username CITEXT NOT NULL, - user_agent TEXT NOT NULL, - authenticated_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000), +CREATE TABLE browser_session ( + php_session_id varchar(256) NOT NULL, + username citext NOT NULL, + user_agent text NOT NULL, + authenticated_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000), - CONSTRAINT pk_session PRIMARY KEY (php_session_id, username, user_agent) + CONSTRAINT pk_browser_session PRIMARY KEY (php_session_id, username, user_agent) ); -CREATE INDEX browser_session_authenticated_at_idx - ON browser_session ( - authenticated_at - ) -; +CREATE INDEX browser_session_authenticated_at_idx ON browser_session (authenticated_at);