Skip to content
Snippets Groups Projects

Fix incorrect renaming migrations

Merged Bob Van Landuyt :neckbeard: requested to merge bvl-fix-already-renamed-paths into master
All threads resolved!

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
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • yorickpeterse-staging
  • Toon Claes
    Toon Claes @to1ne started a thread on commit df5c3f36
  • 1 require 'spec_helper'
    2 require Rails.root.join('db', 'post_migrate', '20170518200835_rename_users_with_renamed_namespace.rb')
    3
    4 describe RenameUsersWithRenamedNamespace, truncate: true do
    5 it 'renames a user that had his namespace renamed to the namespace path' do
    6 other_user = create(:user, username: 'kodingu')
  • added 1 commit

    • 51913c32 - Simpler way of renaming users

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • @yorickpeterse I've adressed most of your comments, one more question left, could you take another look?

  • added 1 commit

    Compare with previous version

  • Douwe Maan resolved all discussions

    resolved all discussions

  • Douwe Maan
  • Douwe Maan
  • Douwe Maan resolved all discussions

    resolved all discussions

  • Douwe Maan resolved all discussions

    resolved all discussions

  • Douwe Maan approved this merge request

    approved this merge request

  • merged

  • Douwe Maan mentioned in commit 09c5885a

    mentioned in commit 09c5885a

  • Douwe Maan mentioned in commit f2768ed6

    mentioned in commit f2768ed6

  • Picked into 9-2-stable will go into 9-2 RC7

  • This affects too many teams to wait :smile:

  • Great job guys on releasing the fix.

    I did notice something else, the links in my case works if I go directly e.g. gitlab.com/kodingu/kodingu, but if I click the link under the kodingu project, it still goes to gitlab.com/koding0u/kodingu.The extra 0 is still there.

    Thanks again for fixing the issue.

    Edited by username-removed-529882
  • @bluetazmanian Right, good catch, that's the project list view that's still cached. A quick workaround for this would be editing the kodingu group, changing the name (not the path :wink:), and then changing it back.

    I'll reopen https://gitlab.com/gitlab-org/gitlab-ce/issues/32530 to look at this.

  • @reprazent Worked as advertised. Kudos to you and the team.

  • Please register or sign in to reply
    Loading