Skip to content

feat: Backfill default PAT prefix to glpat when not set

Lucas Charles requested to merge populate-default-for-pat-prefix into master

What does this MR do and why?

Previously with !73314 (merged) we set the default value of PATs to glpat-, however this does not update any existing instances where the value is not set. With this MR we populate application_settings with the default value explicitly

Relates to #342327 (closed)

Migration

❯ be rake db:migrate
== 20211112155416 PopulateDefaultValueForPersonalAccessTokensPrefix: migrating
-- execute("      UPDATE\n        application_settings\n      SET\n        personal_access_token_prefix = default\n      WHERE\n        personal_access_token_prefix IS NULL\n")
   -> 0.0042s
== 20211112155416 PopulateDefaultValueForPersonalAccessTokensPrefix: migrated (0.0043s)

How to set up and validate locally

Via console

  1. Check ApplicationSetting.current.personal_access_token_prefix
  2. bundle exec rake db:migrate
  3. Check ApplicationSetting.current.personal_access_token_prefix

Via UI

  1. Open Gitlab.com admin panel
  2. Check Personal Access Token prefix
  3. bundle exec rake db:migrate
  4. Check Personal Access Token prefix is now set to glpat-

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Lucas Charles

Merge request reports