Background migration: Update step_url from company path

What does this MR do and why?

Adds a post-deployment background migration to update user_details.onboarding_status.step_url values from either /users/sign_up/company or /users/sign_up/groups/new to /users/sign_up/welcome.

Relates to https://gitlab.com/gitlab-org/gitlab/-/work_items/593994.

Files added:

  • lib/gitlab/background_migration/update_step_url_to_welcome_path.rb — BBM class that updates matching step_url values in batches
  • db/post_migrate/20260715142246_queue_update_step_url_to_welcome_path.rb — post-deployment migration that queues the BBM
  • db/docs/batched_background_migrations/update_step_url_to_welcome_path.yml — BBM dictionary entry
  • spec/lib/gitlab/background_migration/update_step_url_to_welcome_path_spec.rb — BBM spec
  • spec/migrations/20260715142246_queue_update_step_url_to_welcome_path_spec.rb — queue migration spec

Estimated 2.7 million rows to update: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/52139/commands/153587.

Example update query:

UPDATE "user_details"
  SET "onboarding_status" = jsonb_set(
    onboarding_status,
    '{step_url}',
    '"/users/sign_up/welcome"'::jsonb
  )
  WHERE "user_details"."user_id" >= 1
    AND "user_details"."user_id" < 251
    AND (onboarding_status ->> 'step_url' IN ('/users/sign_up/company', '/users/sign_up/groups/new'));

Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/52139/commands/153590

How to set up and validate locally

  1. In a rails console, create a user with step_url set to one of the old paths:
    user = User.last
    user.update!(onboarding_status_step_url: '/users/sign_up/company')
  2. Run the migration:
    Gitlab::BackgroundMigration::UpdateStepUrlToWelcomePath.new(
      start_id: user.user_detail.user_id,
      end_id: user.user_detail.user_id,
      batch_table: :user_details,
      batch_column: :user_id,
      sub_batch_size: 100,
      pause_ms: 0,
      connection: ApplicationRecord.connection
    ).perform
  3. Verify the step_url was updated:
    user.reload.onboarding_status_step_url
    # => "/users/sign_up/welcome"

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Roy Liu

Merge request reports

Loading
Loading