From 27bd29051e7dda9d5be56b6fbadfe0b2d24ccd08 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 25 Nov 2024 12:27:17 -0700 Subject: [PATCH 1/2] add migrations to replace user agent with session id column in logins table --- migrations/000041_logins_keycloak_update.down.sql | 9 +++++++++ migrations/000041_logins_keycloak_update.up.sql | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 migrations/000041_logins_keycloak_update.down.sql create mode 100644 migrations/000041_logins_keycloak_update.up.sql diff --git a/migrations/000041_logins_keycloak_update.down.sql b/migrations/000041_logins_keycloak_update.down.sql new file mode 100644 index 0000000..58a9a2d --- /dev/null +++ b/migrations/000041_logins_keycloak_update.down.sql @@ -0,0 +1,9 @@ +BEGIN; + +SET search_path = public, pg_catalog; + +ALTER TABLE ONLY logins + DROP COLUMN IF EXISTS session_id, + ADD COLUMN IF NOT EXISTS user_agent text; + +COMMIT; diff --git a/migrations/000041_logins_keycloak_update.up.sql b/migrations/000041_logins_keycloak_update.up.sql new file mode 100644 index 0000000..f39eceb --- /dev/null +++ b/migrations/000041_logins_keycloak_update.up.sql @@ -0,0 +1,9 @@ +BEGIN; + +SET search_path = public, pg_catalog; + +ALTER TABLE ONLY logins + DROP COLUMN IF EXISTS user_agent, + ADD COLUMN IF NOT EXISTS session_id uuid; + +COMMIT; From fe18c517321fb3afc3ff3a1ae601b9f15d2d3631 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 2 Dec 2024 10:43:33 -0700 Subject: [PATCH 2/2] also drop logout_time column --- migrations/000041_logins_keycloak_update.down.sql | 3 ++- migrations/000041_logins_keycloak_update.up.sql | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/migrations/000041_logins_keycloak_update.down.sql b/migrations/000041_logins_keycloak_update.down.sql index 58a9a2d..480b466 100644 --- a/migrations/000041_logins_keycloak_update.down.sql +++ b/migrations/000041_logins_keycloak_update.down.sql @@ -4,6 +4,7 @@ SET search_path = public, pg_catalog; ALTER TABLE ONLY logins DROP COLUMN IF EXISTS session_id, - ADD COLUMN IF NOT EXISTS user_agent text; + ADD COLUMN IF NOT EXISTS user_agent text, + ADD COLUMN IF NOT EXISTS logout_time timestamp; COMMIT; diff --git a/migrations/000041_logins_keycloak_update.up.sql b/migrations/000041_logins_keycloak_update.up.sql index f39eceb..e86f67f 100644 --- a/migrations/000041_logins_keycloak_update.up.sql +++ b/migrations/000041_logins_keycloak_update.up.sql @@ -4,6 +4,7 @@ SET search_path = public, pg_catalog; ALTER TABLE ONLY logins DROP COLUMN IF EXISTS user_agent, + DROP COLUMN IF EXISTS logout_time, ADD COLUMN IF NOT EXISTS session_id uuid; COMMIT;