Cleanup access tokens with minimal access level role

What does this MR do and why?

This cleans up access tokens with minimal access level role, as these are not functional. They could be temporarily created because of a bug (fixed here). There are about 700 tokens created with the minimal access level role.

Deleting the bot user created with token creation also deletes the tokens.

This does not need to be a batched background migration, as this should be relatively fast (<10 minutes).

Issue: #467208 (closed)

SQL

SELECT
  DISTINCT "personal_access_tokens"."id" AS alias_0,
  "personal_access_tokens"."id"
FROM
  "personal_access_tokens"
  INNER JOIN "users" ON "users"."id" = "personal_access_tokens"."user_id"
  INNER JOIN "members" ON "members"."user_id" = "users"."id"
WHERE
  "users"."user_type" = 6
  AND "members"."access_level" = 5
ORDER BY
  "personal_access_tokens"."id" ASC
LIMIT
  1000

Plan: https://console.postgres.ai/shared/ea096542-e6c8-4bac-919d-4b18261d4d1d

Edited by Alex Buijs

Merge request reports

Loading