Skip to content

Fix incorrect renaming migrations

This fixes the things that were incorrectly renamed in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10413

  • The users which had their personal namespace renamed, will now have their username renamed to match the namespace

this should be maximum 17 users to update:

SELECT count("users".*) FROM "users" WHERE ("users"."username" ILIKE '-' OR "users"."username" ILIKE 'abuse_reports' OR "users"."username" ILIKE 'api' OR "users"."username" ILIKE 'autocomplete' OR "users"."username" ILIKE 'explore' OR "users"."username" ILIKE 'health_check' OR "users"."username" ILIKE 'import' OR "users"."username" ILIKE 'invites' OR "users"."username" ILIKE 'jwt' OR "users"."username" ILIKE 'koding' OR "users"."username" ILIKE 'member' OR "users"."username" ILIKE 'notification_settings' OR "users"."username" ILIKE 'oauth' OR "users"."username" ILIKE 'sent_notifications' OR "users"."username" ILIKE 'unicorn_test' OR "users"."username" ILIKE 'uploads' OR "users"."username" ILIKE 'users')  ORDER BY "users"."id" DESC

Closes #32526 (closed)

According to https://gitlab.slack.com/archives/C101F3796/p1495181871458006 there are 325 incorrectly renamed root-routes.

The query for this is:

SELECT count("routes".*) FROM "routes" INNER JOIN namespaces ON routes.source_id = namespaces.id WHERE ("routes"."source_type" = 'Namespace' AND "namespaces"."parent_id" IS NULL) AND ("namespaces"."path" ILIKE '-%' OR "namespaces"."path" ILIKE 'abuse_reports%' OR "namespaces"."path" ILIKE 'api%' OR "namespaces"."path" ILIKE 'autocomplete%' OR "namespaces"."path" ILIKE 'explore%' OR "namespaces"."path" ILIKE 'health_check%' OR "namespaces"."path" ILIKE 'import%' OR "namespaces"."path" ILIKE 'invites%' OR "namespaces"."path" ILIKE 'jwt%' OR "namespaces"."path" ILIKE 'koding%' OR "namespaces"."path" ILIKE 'member%' OR "namespaces"."path" ILIKE 'notification_settings%' OR "namespaces"."path" ILIKE 'oauth%' OR "namespaces"."path" ILIKE 'sent_notifications%' OR "namespaces"."path" ILIKE 'unicorn_test%' OR "namespaces"."path" ILIKE 'uploads%' OR "namespaces"."path" ILIKE 'users%') AND (NOT (("namespaces"."path" ILIKE '-0%' OR "namespaces"."path" ILIKE 'abuse_reports0%' OR "namespaces"."path" ILIKE 'api0%' OR "namespaces"."path" ILIKE 'autocomplete0%' OR "namespaces"."path" ILIKE 'explore0%' OR "namespaces"."path" ILIKE 'health_check0%' OR "namespaces"."path" ILIKE 'import0%' OR "namespaces"."path" ILIKE 'invites0%' OR "namespaces"."path" ILIKE 'jwt0%' OR "namespaces"."path" ILIKE 'koding0%' OR "namespaces"."path" ILIKE 'member0%' OR "namespaces"."path" ILIKE 'notification_settings0%' OR "namespaces"."path" ILIKE 'oauth0%' OR "namespaces"."path" ILIKE 'sent_notifications0%' OR "namespaces"."path" ILIKE 'unicorn_test0%' OR "namespaces"."path" ILIKE 'uploads0%' OR "namespaces"."path" ILIKE 'users0%'))) AND ("routes"."path" ILIKE '-0%' OR "routes"."path" ILIKE 'abuse_reports0%' OR "routes"."path" ILIKE 'api0%' OR "routes"."path" ILIKE 'autocomplete0%' OR "routes"."path" ILIKE 'explore0%' OR "routes"."path" ILIKE 'health_check0%' OR "routes"."path" ILIKE 'import0%' OR "routes"."path" ILIKE 'invites0%' OR "routes"."path" ILIKE 'jwt0%' OR "routes"."path" ILIKE 'koding0%' OR "routes"."path" ILIKE 'member0%' OR "routes"."path" ILIKE 'notification_settings0%' OR "routes"."path" ILIKE 'oauth0%' OR "routes"."path" ILIKE 'sent_notifications0%' OR "routes"."path" ILIKE 'unicorn_test0%' OR "routes"."path" ILIKE 'uploads0%' OR "routes"."path" ILIKE 'users0%');

Of course we need to rename all child-routes as well, but that is done in batches for each of these 325 results separately. I haven't been able to look into that.

To see which root namespaces are going to be renamed, and into what they will be renamed, you could run:

SELECT "routes"."path", "namespaces"."path" AS namespace_path FROM "routes" INNER JOIN namespaces ON routes.source_id = namespaces.id WHERE ("routes"."source_type" = 'Namespace' AND "namespaces"."parent_id" IS NULL) AND ("namespaces"."path" ILIKE '-%' OR "namespaces"."path" ILIKE 'abuse_reports%' OR "namespaces"."path" ILIKE 'api%' OR "namespaces"."path" ILIKE 'autocomplete%' OR "namespaces"."path" ILIKE 'explore%' OR "namespaces"."path" ILIKE 'health_check%' OR "namespaces"."path" ILIKE 'import%' OR "namespaces"."path" ILIKE 'invites%' OR "namespaces"."path" ILIKE 'jwt%' OR "namespaces"."path" ILIKE 'koding%' OR "namespaces"."path" ILIKE 'member%' OR "namespaces"."path" ILIKE 'notification_settings%' OR "namespaces"."path" ILIKE 'oauth%' OR "namespaces"."path" ILIKE 'sent_notifications%' OR "namespaces"."path" ILIKE 'unicorn_test%' OR "namespaces"."path" ILIKE 'uploads%' OR "namespaces"."path" ILIKE 'users%') AND (NOT (("namespaces"."path" ILIKE '-0%' OR "namespaces"."path" ILIKE 'abuse_reports0%' OR "namespaces"."path" ILIKE 'api0%' OR "namespaces"."path" ILIKE 'autocomplete0%' OR "namespaces"."path" ILIKE 'explore0%' OR "namespaces"."path" ILIKE 'health_check0%' OR "namespaces"."path" ILIKE 'import0%' OR "namespaces"."path" ILIKE 'invites0%' OR "namespaces"."path" ILIKE 'jwt0%' OR "namespaces"."path" ILIKE 'koding0%' OR "namespaces"."path" ILIKE 'member0%' OR "namespaces"."path" ILIKE 'notification_settings0%' OR "namespaces"."path" ILIKE 'oauth0%' OR "namespaces"."path" ILIKE 'sent_notifications0%' OR "namespaces"."path" ILIKE 'unicorn_test0%' OR "namespaces"."path" ILIKE 'uploads0%' OR "namespaces"."path" ILIKE 'users0%'))) AND ("routes"."path" ILIKE '-0%' OR "routes"."path" ILIKE 'abuse_reports0%' OR "routes"."path" ILIKE 'api0%' OR "routes"."path" ILIKE 'autocomplete0%' OR "routes"."path" ILIKE 'explore0%' OR "routes"."path" ILIKE 'health_check0%' OR "routes"."path" ILIKE 'import0%' OR "routes"."path" ILIKE 'invites0%' OR "routes"."path" ILIKE 'jwt0%' OR "routes"."path" ILIKE 'koding0%' OR "routes"."path" ILIKE 'member0%' OR "routes"."path" ILIKE 'notification_settings0%' OR "routes"."path" ILIKE 'oauth0%' OR "routes"."path" ILIKE 'sent_notifications0%' OR "routes"."path" ILIKE 'unicorn_test0%' OR "routes"."path" ILIKE 'uploads0%' OR "routes"."path" ILIKE 'users0%');

path is what is currently incorrect, and it will be renamed into namespace.path

Closes #32530 (closed)

Edited by Bob Van Landuyt :neckbeard:

Merge request reports

Loading