Skip to content

Backfill route namespace_id for namespaces

Jan Provaznik requested to merge jp-route-backfill-ns into master

What does this MR do and why?

Backfills route's namespace_id for user namespaces and groups (for these records it's just copy of source_id). Projects will be backfilled later (when project namespaces are backfilled for projects).

Related to #346446 (closed)

DB migration

== 20220120123800 BackfillNamespaceIdForNamespaceRoutes: migrating ============
== 20220120123800 BackfillNamespaceIdForNamespaceRoutes: migrated (0.0524s) ===

== 20220209073600 AddTmpIndexRoutesIdForNamespaces: migrating =================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:routes, :id, {:where=>"routes.namespace_id is null and routes.source_type = 'Namespace'", :name=>"tmp_index_for_namespace_id_migration_on_routes", :algorithm=>:concurrently})
   -> 0.0033s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- add_index(:routes, :id, {:where=>"routes.namespace_id is null and routes.source_type = 'Namespace'", :name=>"tmp_index_for_namespace_id_migration_on_routes", :algorithm=>:concurrently})
   -> 0.0083s
-- execute("RESET statement_timeout")
   -> 0.0007s
== 20220209073600 AddTmpIndexRoutesIdForNamespaces: migrated (0.0152s) ========

$ rake db:rollback
== 20220209073600 AddTmpIndexRoutesIdForNamespaces: reverting =================
-- transaction_open?()
   -> 0.0000s
-- indexes(:routes)
   -> 0.0030s
-- execute("SET statement_timeout TO 0")
   -> 0.0008s
-- remove_index(:routes, {:algorithm=>:concurrently, :name=>"tmp_index_for_namespace_id_migration_on_routes"})
   -> 0.0175s
-- execute("RESET statement_timeout")
   -> 0.0004s
== 20220209073600 AddTmpIndexRoutesIdForNamespaces: reverted (0.0242s) ========

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports