Change session from method tracking

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-12-19 15:43:16 +01:00
parent 811bebca48
commit a4964e817c
3 changed files with 57 additions and 30 deletions

View File

@@ -0,0 +1,24 @@
CREATE TYPE session_auth_method AS ENUM (
'PASSWORD',
'SAML'
);
ALTER TABLE sessions ADD COLUMN auth_method session_auth_method;
ALTER TABLE sessions ADD COLUMN authenticated_at TIMESTAMP;
-- Expire all existing sessions as they are not backward compatible
UPDATE sessions SET
expire_reason = 'revoked',
expired_at = NOW(),
updated_at = NOW(),
auth_method = 'PASSWORD',
authenticated_at = created_at
WHERE expire_reason IS NULL;
UPDATE sessions SET
auth_method = 'PASSWORD',
authenticated_at = created_at
WHERE auth_method IS NULL;
ALTER TABLE sessions ALTER COLUMN auth_method SET NOT NULL;
ALTER TABLE sessions ALTER COLUMN authenticated_at SET NOT NULL;