Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright 2025 Element Creations Ltd.
--
-- SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
-- Please see LICENSE in the repository root for full details.


-- Fix a faulty constraint.
-- The condition was incorrectly specified as `revoked_at IS NOT NULL`
-- when `revoked_at IS NULL` was meant.

DROP INDEX personal_access_tokens_personal_session_id_idx;

-- Ensure we can only have one active personal access token in each family.
CREATE UNIQUE INDEX ON personal_access_tokens (personal_session_id) WHERE revoked_at IS NULL;
5 changes: 5 additions & 0 deletions crates/storage-pg/src/personal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ mod tests {
assert!(!token.is_valid(clock.now()));

// Add a second access token, this time without expiration
let _token = repo
.personal_access_token()
.revoke(&clock, token)
.await
.unwrap();
let token = repo
.personal_access_token()
.add(&mut rng, &clock, &session, SECOND_TOKEN, None)
Expand Down
Loading