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
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
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