Skip to content

Commit f020cce

Browse files
committed
Fix UNIQUE constraint on active personal access tokens per session
1 parent 6d2ed5a commit f020cce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Copyright 2025 Element Creations Ltd.
2+
--
3+
-- SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
4+
-- Please see LICENSE in the repository root for full details.
5+
6+
7+
-- Fix a faulty constraint.
8+
-- The condition was incorrectly specified as `revoked_at IS NOT NULL`
9+
-- when `revoked_at IS NULL` was meant.
10+
11+
DROP INDEX personal_access_tokens_personal_session_id_idx;
12+
13+
-- Ensure we can only have one active personal access token in each family.
14+
CREATE UNIQUE INDEX ON personal_access_tokens (personal_session_id) WHERE revoked_at IS NULL;

0 commit comments

Comments
 (0)