Skip to content

Migration for removing ultimate from projects with less than 5 mb

What does this MR do and why?

Disable ultimate features for projects less than 5 MB in size.

This is part of https://gitlab.com/groups/gitlab-org/-/epics/7467 which affects only gitlab.com and we have already announced the change to our users. For the open-source projects, the users need to enroll in our open-source program https://about.gitlab.com/solutions/open-source/.

Query plans

Query 1

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13763/commands/48315

Sample Select Query
SELECT "project_settings"."project_id"
FROM "project_settings"
WHERE "project_settings"."project_id" BETWEEN 10000 AND 10250
  AND "project_settings"."legacy_open_source_license_available" = TRUE
  AND "project_settings"."project_id" >= 10000
ORDER BY "project_settings"."project_id" ASC
LIMIT 250 OFFSET 250;

Query 2

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13763/commands/48314

Sample Update Query
UPDATE 
  "project_settings" 
SET 
  "legacy_open_source_license_available" = FALSE, 
  "updated_at" = '2022-12-08 11:23:14.855890' 
WHERE 
  "project_settings"."project_id" IN (
    SELECT 
      "project_settings"."project_id" 
    FROM 
      "project_settings" 
      INNER JOIN project_statistics ON project_statistics.project_id = project_settings.project_id 
    WHERE 
      "project_settings"."project_id" BETWEEN 10000 
      AND 10250 
      AND "project_settings"."legacy_open_source_license_available" = TRUE 
      AND "project_settings"."project_id" >= 10000 
      AND (
        project_statistics.repository_size < 5242880
      )
  );

Migration output

up

bin/rails db:migrate:up:main VERSION=20221018095434
main: == 20221018095434 ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb: migrating
main: == 20221018095434 ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb: migrated (0.0004s)

down

bin/rails db:migrate:down:main VERSION=20221018095434
main: == 20221018095434 ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb: reverting
main: == 20221018095434 ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb: reverted (0.0004s)

Reversibility

This is a data migration that removes the ultimate license from projects less than 5MB in size. Reversing it would not be straight and would require restoring data from an earlier snapshot.

MR acceptance checklist

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

Related to #376271

Edited by Hitesh Raghuvanshi

Merge request reports

Loading