Skip to content

Add Migration to Update Premium and Ultimate Trial Plan Limits

What does this MR do?

The ci_daily_pipeline_schedule_triggers plan limit for the Ultimate Trial plan and the Premium Trial plan are both set to 0, while the non-trial Ultimate and Premium plans both have a value of 288.

This appears to be because the column was added later: https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3378#note_640735414

See the start of the thread here for more details: https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3378#note_639999445

We want all plan_limits values for the Ultimate and Premium Trial plans to be the same as the non-trial Ultimate and Premium plans. So this MR updates the ci_daily_pipeline_schedule_triggers value for the trial plans to be the same as the non-trial plans.

There is a check of the current plan limits on production here: https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3378#note_649855120

Issue: #322043 (closed), https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3378

Migration Output

This output is from my local development machine, which is a dev environment and also has the ultimate_trial and premium_trial plans. The output should be different if the environment is anything other than dev or com or if the plan limits are not present in the database.

$ bin/rails db:migrate       
== 20210805192450 UpdateTrialPlansCiDailyPipelineScheduleTriggers: migrating ==                                                                                                                                                                                                                                                                                           
-- quote_column_name("ci_daily_pipeline_schedule_triggers")
   -> 0.0000s                                              
-- quote("premium_trial")                                 
   -> 0.0000s                                             
-- quote(288)
   -> 0.0000s
-- execute("INSERT INTO plan_limits (plan_id, \"ci_daily_pipeline_schedule_triggers\")\nSELECT id, '288' FROM plans WHERE name = 'premium_trial' LIMIT 1\nON CONFLICT (plan_id) DO UPDATE SET \"ci_daily_pipeline_schedule_triggers\" = EXCLUDED.\"ci_daily_pipeline_schedule_triggers\";\n")
   -> 0.0068s                                                                      
-- quote_column_name("ci_daily_pipeline_schedule_triggers")
   -> 0.0000s
-- quote("ultimate_trial")
   -> 0.0000s
-- quote(288)
   -> 0.0000s
-- execute("INSERT INTO plan_limits (plan_id, \"ci_daily_pipeline_schedule_triggers\")\nSELECT id, '288' FROM plans WHERE name = 'ultimate_trial' LIMIT 1\nON CONFLICT (plan_id) DO UPDATE SET \"ci_daily_pipeline_schedule_triggers\" = EXCLUDED.\"ci_daily_pipeline_schedule_triggers\";\n")
   -> 0.0009s
== 20210805192450 UpdateTrialPlansCiDailyPipelineScheduleTriggers: migrated (0.0786s) 

$ bin/rails dbconsole
psql (12.7)
Type "help" for help.

gitlabhq_development=# SELECT p.id, p.name, l.ci_daily_pipeline_schedule_triggers FROM plans AS p JOIN plan_limits AS l ON p.id = l.plan_id WHERE p.name IN ('ultimate', 'ultimate_trial', 'premium', 'premium_trial');
 id |      name      | ci_daily_pipeline_schedule_triggers 
----+----------------+-------------------------------------
  9 | premium_trial  |                                 288
  8 | ultimate_trial |                                 288
(2 rows)

gitlabhq_development=# \q
$ VERSION=20210805192450 bin/rails db:migrate:down:main
== 20210805192450 UpdateTrialPlansCiDailyPipelineScheduleTriggers: reverting ==
-- quote_column_name("ci_daily_pipeline_schedule_triggers")
   -> 0.0000s
-- quote("premium_trial")
   -> 0.0000s
-- quote(0)
   -> 0.0000s
-- execute("INSERT INTO plan_limits (plan_id, \"ci_daily_pipeline_schedule_triggers\")\nSELECT id, '0' FROM plans WHERE name = 'premium_trial' LIMIT 1\nON CONFLICT (plan_id) DO UPDATE SET \"ci_daily_pipeline_schedule_triggers\" = EXCLUDED.\"ci_daily_pipeline_schedule_triggers\";\n")
   -> 0.0010s
-- quote_column_name("ci_daily_pipeline_schedule_triggers")
   -> 0.0000s
-- quote("ultimate_trial")
   -> 0.0000s
-- quote(0)
   -> 0.0000s
-- execute("INSERT INTO plan_limits (plan_id, \"ci_daily_pipeline_schedule_triggers\")\nSELECT id, '0' FROM plans WHERE name = 'ultimate_trial' LIMIT 1\nON CONFLICT (plan_id) DO UPDATE SET \"ci_daily_pipeline_schedule_triggers\" = EXCLUDED.\"ci_daily_pipeline_schedule_triggers\";\n")
   -> 0.0007s
== 20210805192450 UpdateTrialPlansCiDailyPipelineScheduleTriggers: reverted (0.0563s) 

$ bin/rails dbconsole
psql (12.7)
Type "help" for help.

gitlabhq_development=# SELECT p.id, p.name, l.ci_daily_pipeline_schedule_triggers FROM plans AS p JOIN plan_limits AS l ON p.id = l.plan_id WHERE p.name IN ('ultimate', 'ultimate_trial', 'premium', 'premium_trial');
 id |      name      | ci_daily_pipeline_schedule_triggers 
----+----------------+-------------------------------------
  9 | premium_trial  |                                   0
  8 | ultimate_trial |                                   0
(2 rows)

gitlabhq_development=# \q
$ 

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Jason Goodman

Merge request reports

Loading