Skip to content

Resolve "Release N - Implement and trigger background migration"

What does this MR do and why?

Creates metadata entries of namespaces in namespace_details table.

Query plan

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/12569/commands/44414

Sample Raw SQL Query
INSERT INTO namespace_details (description, description_html, cached_markdown_version, created_at, updated_at, namespace_id)
  SELECT namespaces.description, namespaces.description_html, namespaces.cached_markdown_version, now(), now(), namespaces.id
  FROM namespaces
  WHERE namespaces.id IN(SELECT "namespaces"."id" FROM "namespaces" WHERE "namespaces"."id" BETWEEN 30000 AND 40000 AND "namespaces"."id" >= 32200 AND "namespaces"."id" < 32400)
  AND namespaces.type <> 'Project'
ON CONFLICT (namespace_id) DO NOTHING;

Migration output

#up

bin/rails db:migrate:up:main VERSION=20220921093355
main: == 20220921093355 ScheduleBackfillNamespaceDetails: migrating =================
main: == 20220921093355 ScheduleBackfillNamespaceDetails: migrated (0.0002s) ========

#down

bin/rails db:migrate:down:main VERSION=20220921093355
main: == 20220921093355 ScheduleBackfillNamespaceDetails: reverting =================
main: == 20220921093355 ScheduleBackfillNamespaceDetails: reverted (0.0002s) ========

Reversability

This adds new rows to namespace_details table and reverting the change might not be easy but in case of any issues we can stop the migration and run another migration to fix the wrong entries. Anyways the column in which this migration is adding data is not being used anywhere.

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 #370582 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading