578320 - Fix add_on_name inconsistency in Clickhouse user_add_on_assignments_history table

What does this MR do and why?

This database migration fixes a data inconsistency issue where add-on names were stored as numbers instead of descriptive text names.

The migration converts numeric values (1-6) to their corresponding text names (like "code_suggestions", "product_analytics", "duo_enterprise", etc.) in a table that tracks user add-on assignment history

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  • Check that the addon name corresponds correctly to GitlabSubscriptions::AddOn model
  • Check how the data looks like on your local, update it if needed before running the migration:
    • $ gdk clickhouse
INSERT INTO user_addon_assignments_history 
(assignment_id, namespace_path, user_id, purchase_id, add_on_name, assigned_at, revoked_at)
VALUES
  (1, 'gitlab-org/', 100, 1001, '1', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(NULL)),
  (2, 'gitlab-org/', 101, 1002, '2', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(NULL)),
  (3, 'acme-corp/', 102, 1003, '3', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(toDateTime64('2025-10-24 12:00:00', 6, 'UTC'))),
  (4, 'acme-corp/', 103, 1004, '4', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(NULL)),
  (5, 'startup-inc/', 104, 1005, '5', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(NULL)),
  (6, 'startup-inc/', 105, 1006, '6', minState(toDateTime64('2025-10-24 10:00:00', 6, 'UTC')), maxState(NULL));
  • Run $ bundle exec rake gitlab:clickhouse:migrate
  • Check if data has changed SELECT * FROM user_addon_assignments_history

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.

Related to #578320

Edited by Amr Taha

Merge request reports

Loading