Skip to content

Backfill project namespace metadata into namespace_details

What does this MR do and why?

Creates metadata entries of project namespaces in namespace_details table.

Query plan

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/12670/commands/44664

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

Migration output

#up

bin/rails db:migrate:up:main VERSION=20221018062308
main: == 20221018062308 ScheduleBackfillProjectNamespaceDetails: migrating ==========
main: == 20221018062308 ScheduleBackfillProjectNamespaceDetails: migrated (0.0153s) =

#down

bin/rails db:migrate:down:main VERSION=20221018062308
main: == 20221018062308 ScheduleBackfillProjectNamespaceDetails: reverting ==========
main: == 20221018062308 ScheduleBackfillProjectNamespaceDetails: reverted (0.0292s) =

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