Let plan limits work when the plans row is missing
What does this MR do and why?
After !258839 (merged) and !259099 (merged), nothing calls Plan.default anymore, and that's what used to create a missing default row in plans. So a new instance can start without that row. The only thing that still needs it is plan_limits.plan_id, which #600314 drops.
GitLab.com already has every row, so nothing changes there.
Part of #571923
How to set up and validate locally
- In a Rails console, run
Plan.where(name: 'default').delete_all. That deletes itsplan_limitsrow too. - As an admin,
GET /api/v4/application/plan_limitsreturns the default limits and doesn't create the row. PUT /api/v4/application/plan_limits?plan_name=default&ci_pipeline_size=1234returns 200 and creates the row.- Delete the row again and run
ActiveRecord::Migration.new.extend(Gitlab::Database::MigrationHelpers).create_or_update_plan_limit('ci_pipeline_size', 'default', 5). The row comes back with the limit set.
Database review
A PUT with no row creates it through PlanLimits#sync_plan_id, which is already on master.
create_or_update_plan_limit
Raw SQL
INSERT INTO plans (name, title, plan_name_uid, created_at, updated_at)
VALUES ('default', 'Default', '1', NOW(), NOW())
ON CONFLICT
DO NOTHING;Plan with the row present, as on GitLab.com: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/65677/commands/170468
Plan with the row missing: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/65101/commands/169945
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.